Compare commits
27 Commits
66a69a4968
...
feat/jntyz
| Author | SHA1 | Date | |
|---|---|---|---|
| 44efd5689b | |||
|
|
0f7af30789 | ||
|
|
b4ed93171c | ||
|
|
6902a16cfa | ||
|
|
60992dc4f6 | ||
|
|
cb21b38287 | ||
|
|
268b63e607 | ||
|
|
d1584184ae | ||
|
|
fea069d795 | ||
|
|
b30af008e0 | ||
|
|
76ec2c8b3c | ||
|
|
c61343a238 | ||
|
|
a78da44f23 | ||
|
|
3b596bfa91 | ||
|
|
f1f3268e84 | ||
|
|
9d3db5e1b3 | ||
|
|
833b6fc208 | ||
|
|
04862d861a | ||
|
|
0a8e853753 | ||
|
|
4eeacf8c52 | ||
|
|
c0647b69e2 | ||
|
|
8c4ea440b6 | ||
|
|
8a302db65a | ||
|
|
3964547e84 | ||
|
|
c387f81225 | ||
|
|
582beb13db | ||
|
|
a1d42a4b27 |
23
pom.xml
23
pom.xml
@@ -170,4 +170,27 @@
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.3.0.RELEASE</version>
|
||||
<configuration>
|
||||
<classifier>exec</classifier>
|
||||
<!-- 指定该Main Class为全局的唯一入口 -->
|
||||
<mainClass>com.xiang.Application</mainClass>
|
||||
<layout>ZIP</layout>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -4,8 +4,10 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class Application {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Application.class);
|
||||
|
||||
77
src/main/java/com/xiang/ApplicationInit.java
Normal file
77
src/main/java/com/xiang/ApplicationInit.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package com.xiang;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.common.enums.RedisKeyConstant;
|
||||
import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.pojo.schedule.ScheduleOpeningConfigDO;
|
||||
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||
import com.xiang.common.utils.RedisService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-08 14:32
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class ApplicationInit implements ApplicationRunner {
|
||||
|
||||
private final IScheduleOpeningConfigService scheduleOpeningConfigService;
|
||||
private final RedisService redisService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
|
||||
log.info("开始加载任务配置!");
|
||||
loadScheduleTask();
|
||||
log.info("任务配置加载完成!");
|
||||
|
||||
log.info("redis key 加载开始!");
|
||||
loadRedisKey();
|
||||
log.info("redis key 加载结束!");
|
||||
}
|
||||
|
||||
private void loadScheduleTask() {
|
||||
List<ScheduleOpeningConfigDO> allSchedules = scheduleOpeningConfigService.getAll();
|
||||
Map<String, ScheduleOpeningConfigDO> map = Maps.newHashMap();
|
||||
if (CollectionUtils.isNotEmpty(allSchedules)) {
|
||||
map.putAll(allSchedules.stream().collect(Collectors.toMap(ScheduleOpeningConfigDO::getBeanName, Function.identity(), (a, b) -> a)));
|
||||
}
|
||||
ScheduleEnums[] enums = ScheduleEnums.values();
|
||||
if (ArrayUtils.isEmpty(enums)) {
|
||||
log.info("暂无需要配置的");
|
||||
return;
|
||||
}
|
||||
List<ScheduleOpeningConfigDO> list = Lists.newArrayList();
|
||||
for (ScheduleEnums scheduleEnum : enums) {
|
||||
if (map.containsKey(scheduleEnum.getTaskName())) {
|
||||
continue;
|
||||
}
|
||||
ScheduleOpeningConfigDO scheduleOpeningConfigDO = new ScheduleOpeningConfigDO();
|
||||
scheduleOpeningConfigDO.setModule(scheduleEnum.getModuleCode());
|
||||
scheduleOpeningConfigDO.setBeanName(scheduleEnum.getTaskName());
|
||||
scheduleOpeningConfigDO.setStatus(1);
|
||||
list.add(scheduleOpeningConfigDO);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
scheduleOpeningConfigService.saveBatch(list);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadRedisKey() {
|
||||
redisService.set(RedisKeyConstant.JNTYZX_SUBSCRIBE_TIME_KEY, "18:00");
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,17 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisPassword;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
@Bean
|
||||
@@ -35,7 +41,6 @@ public class RedisConfig {
|
||||
|
||||
template.setValueSerializer(jackson2JsonRedisSerializer);
|
||||
template.setHashValueSerializer(jackson2JsonRedisSerializer);
|
||||
|
||||
template.afterPropertiesSet();
|
||||
return template;
|
||||
}
|
||||
@@ -44,4 +49,18 @@ public class RedisConfig {
|
||||
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory factory) {
|
||||
return new StringRedisTemplate(factory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisConnectionFactory redisConnectionFactory(RedisProperties props) {
|
||||
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
|
||||
config.setHostName(props.getHost());
|
||||
config.setPort(Integer.parseInt(props.getPort()));
|
||||
config.setPassword(RedisPassword.of(props.getPassword()));
|
||||
config.setDatabase(props.getDatabase());
|
||||
|
||||
LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder()
|
||||
.commandTimeout(Duration.ofSeconds(3))
|
||||
.build();
|
||||
return new LettuceConnectionFactory(config, clientConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class RedisProperties {
|
||||
private String host;
|
||||
private String port;
|
||||
private String password;
|
||||
private Integer database = 0;
|
||||
private Integer database;
|
||||
|
||||
public String getAddress() {
|
||||
return "redis://" + host + ":" + port;
|
||||
|
||||
47
src/main/java/com/xiang/common/enums/JntyzxUrlConstant.java
Normal file
47
src/main/java/com/xiang/common/enums/JntyzxUrlConstant.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.xiang.common.enums;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 13:46
|
||||
*/
|
||||
public class JntyzxUrlConstant {
|
||||
|
||||
/**
|
||||
* 江南体育中心基础URL
|
||||
*/
|
||||
private final static String GNTYZX_BASE_URL = "https://jntyzx.cn:8443";
|
||||
|
||||
/**
|
||||
* 查询当天的场地信息
|
||||
*/
|
||||
public final static String QUERY_TODAY_SUBSCRIBE_URL = GNTYZX_BASE_URL + "/GYM-JN/multi/Subscribe/getSubscribeByToday";
|
||||
/**
|
||||
* 查询明天场地信息
|
||||
*/
|
||||
public final static String QUERY_TOMORROW_SUBSCRIBE_URL = GNTYZX_BASE_URL + "/GYM-JN/multi/Subscribe/getSubscribeByTomorrow";
|
||||
|
||||
/**
|
||||
* 订阅场地
|
||||
*/
|
||||
public final static String ADD_SUBSCRIBE = GNTYZX_BASE_URL + "/GYM-JN/multi/Subscribe/addSubscribe";
|
||||
|
||||
/**
|
||||
* 订单信息
|
||||
*/
|
||||
public final static String ORDER_INFO = GNTYZX_BASE_URL + "/GYM-JN/multi/busiOrder/queryOrderInfo";
|
||||
|
||||
/**
|
||||
* 心跳监测接口
|
||||
*/
|
||||
public final static String HEALTH_DECLARATION = GNTYZX_BASE_URL + "/GYM-JN//busi/healthDeclaration/addUserPrivacy";
|
||||
|
||||
/**
|
||||
* 校验会员卡状态
|
||||
*/
|
||||
public final static String CHECK_NUM = GNTYZX_BASE_URL + "/GYM-JN/multi/Subscribe/checkDefaultsNum";
|
||||
|
||||
/**
|
||||
* 根据openId查询会员卡信息
|
||||
*/
|
||||
public final static String QUERY_BY_OPEN_ID = GNTYZX_BASE_URL + "/GYM-JN/multi/xfConsumer/queryByOpenId";
|
||||
}
|
||||
38
src/main/java/com/xiang/common/enums/RedisKeyConstant.java
Normal file
38
src/main/java/com/xiang/common/enums/RedisKeyConstant.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.xiang.common.enums;
|
||||
|
||||
|
||||
import com.xiang.common.utils.DateUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 10:43
|
||||
*/
|
||||
public class RedisKeyConstant {
|
||||
|
||||
public static final String JNTYZX_ORDER_CREATE_KEY = "jntyzx:order:create:orderId:";
|
||||
|
||||
public static final String JNTUZX_ORDER_PEEK_KEY = "jntyzx:order:peek:user:";
|
||||
|
||||
public static final String JNTYZX_VENUE_MSG_SEND_KEY = "jntyzx:order:venue:msg:send";
|
||||
|
||||
private static final String JNTYZX_VENUE_SUBSCRIBE_KEY = "jntyzx:venue:subscribe:";
|
||||
|
||||
private static final String JNTYZX_ORDER_CLOSE_CARD_KEY = "jntyzx:order:close:card:";
|
||||
|
||||
public static String getCloseCardKey(String username) {
|
||||
return JNTYZX_ORDER_CLOSE_CARD_KEY + username + ":" +getDate();
|
||||
}
|
||||
|
||||
public static String getVenueSubscribeKey(String placeName) {
|
||||
return JNTYZX_VENUE_SUBSCRIBE_KEY + placeName + ":" + getDate();
|
||||
}
|
||||
|
||||
public static final String JNTYZX_SUBSCRIBE_TIME_KEY = "jntyzx:subscribe:time";
|
||||
|
||||
public static String getDate() {
|
||||
LocalDate now = LocalDate.now();
|
||||
return ":" + DateUtils.getDateFromDate(now);
|
||||
}
|
||||
}
|
||||
@@ -10,18 +10,40 @@ public enum ScheduleEnums {
|
||||
/**
|
||||
* 0:glados 1:芬玩岛 2:江体小程序 3:江体zlb 4:DDNS
|
||||
*/
|
||||
|
||||
/**
|
||||
* Aliyun DDNS任务
|
||||
*/
|
||||
DOMAIN_DYNAMIC_ANALYSIS_TASK(4, "domain", "domainDynamicAnalysisTask"),
|
||||
|
||||
/**
|
||||
* Glados任务
|
||||
*/
|
||||
GLADOS_CHECK_IN_TASK(0, "glados", "gladosCheckInTask"),
|
||||
|
||||
/**
|
||||
* 江体 ZLB任务
|
||||
*/
|
||||
ZLB_LOGIN_TASK(3, "zlb", "zlbLoginTask"),
|
||||
ZLB_TOKEN_CHECK_TASK(3, "zlb", "zlbTokenCheckTask"),
|
||||
ZLB_SITE_QUERY_TASK(3, "zlb", "zlbSiteQueryTask"),
|
||||
ZLB_SITE_DAY_TASK(3, "zlb", "zlbSiteDayTask"),
|
||||
ZLB_ORDER_CREATE_TASK(3, "zlb", "zlbOrderCreateTask"),
|
||||
ZLB_USER_CONFIG_TASK(3, "zlb", "zlbUserConfigTask"),
|
||||
|
||||
|
||||
JNTYZX_TOKEN_REFRESH_TASK(4, "jt-miniApp", "jntyzxTokenRefreshTask"),
|
||||
JNTYZX_VENUE_INFO_PULL_TASK(4, "jt-miniApp", "jntyzxVenuePullTask"),
|
||||
JNTYZX_ORDER_SUBSCRIBE_TASK(4, "jt-miniApp", "jntyzxOrderSubscribeTask"),
|
||||
JNTYZX_VENUE_TODAY_SUBSCRIBE_TASK(4, "jt-miniApp", "jntyzxVenueTodaySubscribeTask"),
|
||||
JNTYZX_VENUE_TOMORROW_PULL_TASK(4, "jt-miniApp", "jntyzxVenueTodayPullTask"),
|
||||
JNTYZX_USER_INFO_CONFIG(4, "jt-miniApp", "jntyzxUserInfoConfigTask"),
|
||||
JNTYZX_VENUE_INFO_TODAY_RESULT_TASK(4, "jt-miniApp", "jtVenueInfoTodayResultTask"),
|
||||
JNTYZX_VENUE_INFO_TOMORROW_RESULT_TASK(4, "jt-miniApp", "jtVenueInfoTomorrowResultTask"),
|
||||
|
||||
;
|
||||
|
||||
private final Integer modeleCode;
|
||||
private final Integer moduleCode;
|
||||
private final String module;
|
||||
private final String taskName;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ import lombok.Getter;
|
||||
public enum YcCodeTypeEnum {
|
||||
|
||||
YC_10118(10118, "中文字符 1~4位 plus 其他类型准确率不满足 可使用本类型"),
|
||||
YC_6246(30100, "通用中文点选1")
|
||||
YC_6246(30100, "通用中文点选1"),
|
||||
YC_310700(310700, "适合Zlb使用的word click")
|
||||
|
||||
;
|
||||
private final Integer type;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.OrderInfoDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 10:59
|
||||
*/
|
||||
public interface IOrderCreateInfoManage extends IService<OrderInfoDO> {
|
||||
|
||||
|
||||
List<OrderInfoDO> queryNoPayOrder();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserInfoDO;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 10:17
|
||||
*/
|
||||
public interface IUserInfoManage extends IService<UserInfoDO> {
|
||||
boolean delAll();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserRestrictionInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IUserRestrictionManage extends IService<UserRestrictionInfo> {
|
||||
|
||||
UserRestrictionInfo queryByUserId(Long userId);
|
||||
|
||||
List<UserRestrictionInfo> queryByIdList(List<Long> idList);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.UserQueryReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 09:19
|
||||
*/
|
||||
public interface IUserTokenInfoManage extends IService<UserTokenInfoDO> {
|
||||
List<UserTokenInfoDO> listUser();
|
||||
UserTokenInfoDO getByName(String name);
|
||||
|
||||
List<UserTokenInfoDO> listCanOrder();
|
||||
|
||||
List<UserTokenInfoDO> queryByList(UserQueryReq req);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 15:50
|
||||
*/
|
||||
public interface IVenueInfoManage extends IService<VenueInfoDO> {
|
||||
|
||||
List<VenueInfoDO> queryByDate(LocalDate date);
|
||||
|
||||
List<VenueInfoDO> queryByType(LocalDate date, Integer type);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.OrderInfoDO;
|
||||
import com.xiang.common.mapper.JntyzxOrderCreateInfoMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 10:59
|
||||
*/
|
||||
@Service
|
||||
public class OrderCreateInfoManageImpl extends ServiceImpl<JntyzxOrderCreateInfoMapper, OrderInfoDO> implements IOrderCreateInfoManage {
|
||||
|
||||
|
||||
@Override
|
||||
public List<OrderInfoDO> queryNoPayOrder() {
|
||||
LambdaQueryWrapper<OrderInfoDO> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.eq(OrderInfoDO::getOrderStatus, 0);
|
||||
return baseMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.mapper.JntyzxUserInfoMapper;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserInfoDO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 10:17
|
||||
*/
|
||||
@Service
|
||||
public class UserInfoManageImpl extends ServiceImpl<JntyzxUserInfoMapper, UserInfoDO> implements IUserInfoManage {
|
||||
@Override
|
||||
public boolean delAll() {
|
||||
return baseMapper.delAll() > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserRestrictionInfo;
|
||||
import com.xiang.common.mapper.JntyzxUserRestrictionInfoMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserRestrictionManageImpl extends ServiceImpl<JntyzxUserRestrictionInfoMapper, UserRestrictionInfo> implements IUserRestrictionManage {
|
||||
@Override
|
||||
public UserRestrictionInfo queryByUserId(Long userId) {
|
||||
LambdaQueryWrapper<UserRestrictionInfo> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.eq(UserRestrictionInfo::getUserId, userId);
|
||||
return baseMapper.selectOne(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRestrictionInfo> queryByIdList(List<Long> idList) {
|
||||
LambdaQueryWrapper<UserRestrictionInfo> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.in(UserRestrictionInfo::getUserId, idList);
|
||||
return baseMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.UserQueryReq;
|
||||
import com.xiang.common.mapper.JntyzxUserTokenInfoMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 09:19
|
||||
*/
|
||||
@Service
|
||||
public class UserTokenInfoManageImpl extends ServiceImpl<JntyzxUserTokenInfoMapper, UserTokenInfoDO> implements IUserTokenInfoManage {
|
||||
@Override
|
||||
public List<UserTokenInfoDO> listUser() {
|
||||
LambdaQueryWrapper<UserTokenInfoDO> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.eq(UserTokenInfoDO::getStatus, 1);
|
||||
return baseMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserTokenInfoDO getByName(String name) {
|
||||
LambdaQueryWrapper<UserTokenInfoDO> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.eq(UserTokenInfoDO::getStatus, 1);
|
||||
lambdaQueryWrapper.eq(UserTokenInfoDO::getName, name);
|
||||
lambdaQueryWrapper.last("limit 1");
|
||||
return baseMapper.selectOne(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserTokenInfoDO> listCanOrder() {
|
||||
LambdaQueryWrapper<UserTokenInfoDO> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.eq(UserTokenInfoDO::getStatus, 1);
|
||||
lambdaQueryWrapper.eq(UserTokenInfoDO::getIsOrder, 1);
|
||||
lambdaQueryWrapper.eq(UserTokenInfoDO::getIsRestriction, 0);
|
||||
return baseMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserTokenInfoDO> queryByList(UserQueryReq req) {
|
||||
LambdaQueryWrapper<UserTokenInfoDO> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
if (StringUtils.isNotBlank(req.getName())) {
|
||||
lambdaQueryWrapper.like(UserTokenInfoDO::getName, req.getName());
|
||||
}
|
||||
if (StringUtils.isNotBlank(req.getOpenId())) {
|
||||
lambdaQueryWrapper.eq(UserTokenInfoDO::getOpenId, req.getOpenId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(req.getMemberCardNo())) {
|
||||
lambdaQueryWrapper.eq(UserTokenInfoDO::getMemberCardNo, req.getMemberCardNo());
|
||||
}
|
||||
if (Objects.nonNull(req.getStatus())) {
|
||||
lambdaQueryWrapper.eq(UserTokenInfoDO::getStatus, req.getStatus());
|
||||
}
|
||||
if (Objects.nonNull(req.getIsRestriction())) {
|
||||
lambdaQueryWrapper.eq(UserTokenInfoDO::getIsRestriction, req.getIsRestriction());
|
||||
}
|
||||
if (Objects.nonNull(req.getIsOrder())) {
|
||||
lambdaQueryWrapper.eq(UserTokenInfoDO::getIsOrder, req.getIsOrder());
|
||||
}
|
||||
return baseMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.mapper.JntyzxVenueInfoMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 15:51
|
||||
*/
|
||||
@Service
|
||||
public class VenueInfoManageImpl extends ServiceImpl<JntyzxVenueInfoMapper, VenueInfoDO> implements IVenueInfoManage {
|
||||
|
||||
public List<VenueInfoDO> queryByDate(LocalDate date) {
|
||||
LambdaQueryWrapper<VenueInfoDO> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(VenueInfoDO::getDate, date);
|
||||
return baseMapper.selectList(lqw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VenueInfoDO> queryByType(LocalDate date, Integer type) {
|
||||
LambdaQueryWrapper<VenueInfoDO> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(VenueInfoDO::getDate, date);
|
||||
lqw.eq(VenueInfoDO::getType, type);
|
||||
return baseMapper.selectList(lqw);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbPayOrder;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 15:11
|
||||
*/
|
||||
public interface IZlbOrderInfoManage extends IService<ZlbPayOrder> {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.mapper.ZlbOrderInfoMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbPayOrder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 15:11
|
||||
*/
|
||||
@Service
|
||||
public class ZlbOrderInfoManageImpl extends ServiceImpl<ZlbOrderInfoMapper, ZlbPayOrder> implements IZlbOrderInfoManage {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbSiteInfo;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.mapper.ZlbSiteInfoMapper;
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author a123
|
||||
* @description 针对表【zlb_token_info】的数据库操作Service
|
||||
@@ -11,4 +13,6 @@ import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||
public interface ZlbTokenInfoService extends IService<ZlbTokenInfo> {
|
||||
|
||||
ZlbTokenInfo queryByName(String name);
|
||||
|
||||
List<ZlbTokenInfo> getAllUsers();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@@ -7,6 +7,8 @@ import com.xiang.common.mapper.ZlbTokenInfoMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author a123
|
||||
* @description 针对表【zlb_token_info】的数据库操作Service实现
|
||||
@@ -22,6 +24,13 @@ public class ZlbTokenInfoServiceImpl extends ServiceImpl<ZlbTokenInfoMapper, Zlb
|
||||
wrapper.eq(ZlbTokenInfo::getName, name);
|
||||
return this.getOne(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ZlbTokenInfo> getAllUsers() {
|
||||
LambdaQueryWrapper<ZlbTokenInfo> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.eq(ZlbTokenInfo::getIsDel, 0);
|
||||
return baseMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
public interface ZlbUserInfoService extends IService<ZlbUserInfo> {
|
||||
|
||||
/**
|
||||
* 查询日期内未预订的用户
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
List<ZlbUserInfo> getNoBookUsers(LocalDate date);
|
||||
|
||||
int delAll();
|
||||
|
||||
}
|
||||
@@ -1,14 +1,26 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.mapper.ZlbUserInfoMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ZlbUserInfoServiceImpl extends ServiceImpl<ZlbUserInfoMapper, ZlbUserInfo>
|
||||
implements ZlbUserInfoService {
|
||||
|
||||
@Override
|
||||
public List<ZlbUserInfo> getNoBookUsers(LocalDate date) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delAll() {
|
||||
return baseMapper.deleteAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.OrderInfoDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 10:58
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface JntyzxOrderCreateInfoMapper extends BaseMapper<OrderInfoDO> {
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserInfoDO;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 10:16
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface JntyzxUserInfoMapper extends BaseMapper<UserInfoDO> {
|
||||
|
||||
@Delete("delete from jntyzx_user_info where 1=1")
|
||||
int delAll();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserRestrictionInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface JntyzxUserRestrictionInfoMapper extends BaseMapper<UserRestrictionInfo> {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 09:18
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface JntyzxUserTokenInfoMapper extends BaseMapper<UserTokenInfoDO> {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 15:48
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface JntyzxVenueInfoMapper extends BaseMapper<VenueInfoDO> {
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -9,6 +10,8 @@ import org.springframework.stereotype.Repository;
|
||||
@Mapper
|
||||
public interface ZlbUserInfoMapper extends BaseMapper<ZlbUserInfo> {
|
||||
|
||||
@Delete("delete from zlb_user_info where 1=1")
|
||||
int deleteAll();
|
||||
}
|
||||
|
||||
|
||||
|
||||
29
src/main/java/com/xiang/common/pojo/TrackPoint.java
Normal file
29
src/main/java/com/xiang/common/pojo/TrackPoint.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.xiang.common.pojo;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-07 15:57
|
||||
*/
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 轨迹点类
|
||||
*/
|
||||
@Data
|
||||
public class TrackPoint {
|
||||
public int x, y, t;
|
||||
public String type;
|
||||
|
||||
public TrackPoint(int x, int y, int t, String type) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.t = t;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("{\"x\":%d,\"y\":%d,\"t\":%d,\"type\":\"%s\"}", x, y, t, type);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xiang.common.pojo.code;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -9,7 +10,7 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class YcCodeRequest {
|
||||
/**
|
||||
* 图片
|
||||
* 图片 base64
|
||||
*/
|
||||
private String image;
|
||||
/**
|
||||
@@ -21,4 +22,10 @@ public class YcCodeRequest {
|
||||
*/
|
||||
private Integer type;
|
||||
private String extra;
|
||||
|
||||
/**
|
||||
* 模板图片 base64
|
||||
*/
|
||||
@JSONField(name = "label_image")
|
||||
private String labelImage;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xiang.common.pojo.glados.resp;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-08 15:47
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GladosPointsHistoryResp {
|
||||
|
||||
private String asset;
|
||||
private String balance;
|
||||
private String business;
|
||||
private String change;
|
||||
private String detail;
|
||||
private Long id;
|
||||
private Long time;
|
||||
@JSONField(name = "user_id")
|
||||
private Long userId;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.xiang.common.pojo.glados.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-08 15:46
|
||||
*/
|
||||
@Data
|
||||
public class GladosPointsResp {
|
||||
private Integer code;
|
||||
private List<GladosPointsHistoryResp> history;
|
||||
private Plans plans;
|
||||
private String points;
|
||||
}
|
||||
|
||||
@Data
|
||||
class Plans {
|
||||
|
||||
private Plan plan100;
|
||||
private Plan plan200;
|
||||
private Plan plan500;
|
||||
}
|
||||
@Data
|
||||
class Plan {
|
||||
private Integer days;
|
||||
private Integer points;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 13:55
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class VenueListDTO {
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
private String date;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
private String sjName;
|
||||
|
||||
/**
|
||||
* 场地名称
|
||||
*/
|
||||
private String placeName;
|
||||
|
||||
/**
|
||||
* 联系人
|
||||
*/
|
||||
private String contacts;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 10:57
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("jntyzx_order_create_info")
|
||||
public class OrderInfoDO {
|
||||
private Long id;
|
||||
/**
|
||||
* 订单id
|
||||
*/
|
||||
private String orderId;
|
||||
|
||||
/**
|
||||
* 参数
|
||||
*/
|
||||
private String params;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 订单创建人
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 场地号
|
||||
*/
|
||||
private String placeName;
|
||||
|
||||
/**
|
||||
* 所属日期
|
||||
*/
|
||||
private LocalDate date;
|
||||
|
||||
/**
|
||||
* 订单状态 (0:待付款,1:已付款)
|
||||
*/
|
||||
private Integer orderStatus;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 09:54
|
||||
*/
|
||||
@Data
|
||||
@TableName("jntyzx_user_info")
|
||||
public class UserInfoDO {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Integer loginInfoId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 星期几
|
||||
*/
|
||||
private String week;
|
||||
|
||||
/**
|
||||
* 分配的任务参数
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 场地信息
|
||||
*/
|
||||
private String placeName;
|
||||
|
||||
/**
|
||||
* 时间id111
|
||||
*/
|
||||
private String siteTimeName;
|
||||
|
||||
/**
|
||||
* 是否开抢0-抢,1-不抢
|
||||
*/
|
||||
private Integer isBook;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("jntyzx_user_restriction")
|
||||
public class UserRestrictionInfo {
|
||||
|
||||
private Long id;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 封禁截止时间
|
||||
*/
|
||||
private LocalDateTime restrictionDeadline;
|
||||
/**
|
||||
* 封禁原因
|
||||
*/
|
||||
private String restrictionDesc;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 09:18
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("jntyzx_user_token_info")
|
||||
public class UserTokenInfoDO {
|
||||
private Long id;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* wx openid
|
||||
*/
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
* 状态(0:禁用 1:启用)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否可以下单 (0:否 1:是)
|
||||
*/
|
||||
private Integer isOrder;
|
||||
|
||||
/**
|
||||
* 会员卡号
|
||||
*/
|
||||
@TableField("member_card_no")
|
||||
private String memberCardNo;
|
||||
|
||||
/**
|
||||
* 是否封禁 0:否 1:是
|
||||
*/
|
||||
@TableField("is_restriction")
|
||||
private Integer isRestriction;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 15:48
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("jntyzx_venue_info")
|
||||
public class VenueInfoDO {
|
||||
private Long id;
|
||||
/**
|
||||
* 场地名称
|
||||
*/
|
||||
private String placeName;
|
||||
|
||||
/**
|
||||
* 所属日期
|
||||
*/
|
||||
private LocalDate date;
|
||||
|
||||
/**
|
||||
* 场地信息三方主键
|
||||
*/
|
||||
private Long placeMainId;
|
||||
|
||||
/**
|
||||
* 场地id
|
||||
*/
|
||||
private Integer placeId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer scheduleId;
|
||||
|
||||
/**
|
||||
* 时间范围
|
||||
*/
|
||||
private String sjName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 联系人
|
||||
*/
|
||||
private String contacts;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
private BigDecimal money;
|
||||
private String className;
|
||||
private String classCode;
|
||||
private String appointments;
|
||||
private String cTypeCode;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.req;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 16:34
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SubscribeRequest {
|
||||
private JSONObject jsonObject;
|
||||
private List<SubscribeVo> subscribeVos;
|
||||
private String bookTime;
|
||||
private Integer paymentMethod;
|
||||
private String svCiphertext;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.req;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 16:35
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SubscribeVo {
|
||||
private int id;
|
||||
|
||||
private String ballCourtId;
|
||||
|
||||
private String sjName;
|
||||
|
||||
private String scheduleId;
|
||||
|
||||
private String placeName;
|
||||
|
||||
private int placeId;
|
||||
|
||||
private String type;
|
||||
|
||||
private String className;
|
||||
|
||||
private String classCode;
|
||||
|
||||
private BigDecimal money;
|
||||
|
||||
private String contacts;
|
||||
|
||||
private String contactNumber;
|
||||
|
||||
private String memberNumber;
|
||||
|
||||
private String appointments;
|
||||
|
||||
private String operator;
|
||||
|
||||
private String endTime;
|
||||
|
||||
private String beginTime;
|
||||
|
||||
private int specOneTimes;
|
||||
|
||||
private String ctypeCode;
|
||||
|
||||
private int isWhole;
|
||||
|
||||
private String orderId;
|
||||
|
||||
private int votesnum;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.req;
|
||||
|
||||
import lombok.Data;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@Data
|
||||
public class UserAddReq {
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
private String token;
|
||||
/**
|
||||
* wx openId
|
||||
*/
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
* 会员卡号
|
||||
*/
|
||||
private String memberCardNo;
|
||||
|
||||
/**
|
||||
* 状态 0:禁用 1:启用
|
||||
*/
|
||||
private Integer status;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-03-24 16:40
|
||||
*/
|
||||
@Data
|
||||
public class UserQueryReq {
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* wx openId
|
||||
*/
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
* 会员卡号
|
||||
*/
|
||||
private String memberCardNo;
|
||||
|
||||
/**
|
||||
* 状态 0:禁用 1:启用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否可以下单 0:否 1:是
|
||||
*/
|
||||
private Integer isOrder;
|
||||
|
||||
/**
|
||||
* 是否封禁 0:否 1:是
|
||||
*/
|
||||
private Integer isRestriction;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class UserStatusUpdateReq {
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* status
|
||||
*/
|
||||
private Integer status;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class UserTokenUpdateReq {
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
private String token;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class UsernameReq {
|
||||
private String username;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.req;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-04-09 09:39
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class VenueInfoQueryRequest{
|
||||
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
private LocalDate date;
|
||||
/**
|
||||
* 时间段 例如 20:00-21:00
|
||||
*/
|
||||
private String sj;
|
||||
|
||||
/**
|
||||
* 场地名称
|
||||
*/
|
||||
private String placeName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-04-09 10:00
|
||||
*/
|
||||
@Data
|
||||
public class VenueInfoSubscribeRequest {
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-05-14 14:38
|
||||
*/
|
||||
@Data
|
||||
public class JntyzxResponse<T> {
|
||||
private Boolean success;
|
||||
|
||||
private String message;
|
||||
|
||||
private Integer code;
|
||||
|
||||
private T result;
|
||||
|
||||
private Long timestamp;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.resp;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-03-24 16:40
|
||||
*/
|
||||
@Data
|
||||
public class JtUserVo {
|
||||
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
private String token;
|
||||
/**
|
||||
* wx:openId
|
||||
*/
|
||||
private String openId;
|
||||
/**
|
||||
* 账号状态:
|
||||
* 状态(0:禁用 1:启用)
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd Hh:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd Hh:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
/**
|
||||
* 江南体育中心会员卡号
|
||||
*/
|
||||
private String memberCardNo;
|
||||
/**
|
||||
* 是否可以下单
|
||||
*/
|
||||
private Boolean isOrder;
|
||||
/**
|
||||
* 是否封禁
|
||||
*/
|
||||
private Boolean isRestriction;
|
||||
/**
|
||||
* 封禁结束时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd Hh:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd Hh:mm:ss")
|
||||
private LocalDateTime restrictionDeadline;
|
||||
/**
|
||||
* 封禁缘由
|
||||
*/
|
||||
private String restrictionDesc;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.resp;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 10:36
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class OrderCreateResp {
|
||||
|
||||
private String id;
|
||||
private String countDownNum;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.resp;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-04-09 09:42
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class VenueInfoQueryResp {
|
||||
|
||||
/**
|
||||
* 场地名称
|
||||
*/
|
||||
private String placeName;
|
||||
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
private LocalDate date;
|
||||
|
||||
/**
|
||||
* 时间范围
|
||||
*/
|
||||
private String sjName;
|
||||
|
||||
/**
|
||||
* 价格
|
||||
*/
|
||||
private BigDecimal money;
|
||||
|
||||
/**
|
||||
* 联系人
|
||||
*/
|
||||
private String contacts;
|
||||
|
||||
/**
|
||||
* 0:可订购 2:zlb 4:已订购
|
||||
*/
|
||||
private Integer type;
|
||||
private Long placeMainId;
|
||||
private Integer placeId;
|
||||
private Integer scheduleId;
|
||||
private String className;
|
||||
private String classCode;
|
||||
private String appointments;
|
||||
private String cTypeCode;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.resp.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-05-14 14:37
|
||||
*/
|
||||
@Data
|
||||
public class QueryVenueResponse {
|
||||
private List<TimeList> timeList;
|
||||
|
||||
private List<VenueList> venue;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.resp.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-05-14 14:45
|
||||
*/
|
||||
@Data
|
||||
public class SitePositionList {
|
||||
private Long id;
|
||||
|
||||
private String ballCourtId;
|
||||
|
||||
private String sjName;
|
||||
|
||||
private String scheduleId;
|
||||
|
||||
private String placeName;
|
||||
|
||||
private Integer placeId;
|
||||
|
||||
private Integer type;
|
||||
|
||||
private String className;
|
||||
|
||||
private String classCode;
|
||||
|
||||
private BigDecimal money;
|
||||
|
||||
private String contacts;
|
||||
|
||||
private String contactNumber;
|
||||
|
||||
private String memberNumber;
|
||||
|
||||
private String appointments;
|
||||
|
||||
private String operator;
|
||||
|
||||
private String endTime;
|
||||
|
||||
private String beginTime;
|
||||
|
||||
private Integer specOneTimes;
|
||||
|
||||
private String ctypeCode;
|
||||
|
||||
private String isWhole;
|
||||
|
||||
private Long orderId;
|
||||
|
||||
private Integer votesnum;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.resp.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-05-14 14:39
|
||||
*/
|
||||
@Data
|
||||
public class TimeList {
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
private String beginTime;
|
||||
|
||||
private String endTime;
|
||||
|
||||
private String type;
|
||||
|
||||
private String isenable;
|
||||
|
||||
private String operator;
|
||||
|
||||
private String createtime;
|
||||
|
||||
private String remarks;
|
||||
|
||||
private String default01;
|
||||
private String default02;
|
||||
private String default03;
|
||||
private String votesnum;
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.resp.query;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UserInfoResponse {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 会员卡号
|
||||
*/
|
||||
private String consCard;
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String consName;
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String consSex;
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String consIdCard;
|
||||
/**
|
||||
* 固定电话
|
||||
*/
|
||||
private String consTel;
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String consHandSet;
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String consUnit;
|
||||
/**
|
||||
* 照片
|
||||
*/
|
||||
private String consPhoto;
|
||||
private Integer consWaste;
|
||||
/**
|
||||
* 会员卡号
|
||||
*/
|
||||
private String consNumber;
|
||||
private BigDecimal consMin;
|
||||
private Integer consProp;
|
||||
/**
|
||||
* 注册年
|
||||
*/
|
||||
private String consYear;
|
||||
/**
|
||||
* 注册月
|
||||
*/
|
||||
private String consMonth;
|
||||
/**
|
||||
* 注册日
|
||||
*/
|
||||
private String consDay;
|
||||
private boolean consIflag;
|
||||
/**
|
||||
* 注册时间
|
||||
*/
|
||||
private LocalDateTime consTimes;
|
||||
/**
|
||||
* openId
|
||||
*/
|
||||
private String openId;
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String photoUrl;
|
||||
/**
|
||||
* 会员
|
||||
*/
|
||||
private Integer consVip;
|
||||
/**
|
||||
* 会员等级号
|
||||
*/
|
||||
private String consVipCode;
|
||||
|
||||
private String eleCardNum;
|
||||
private Integer appointmentEligibility;
|
||||
/**
|
||||
* 封禁截止日期
|
||||
*/
|
||||
@JSONField(name = "restrictionDeadline")
|
||||
private String restrictionDeadline;
|
||||
/**
|
||||
* 封禁原因
|
||||
*/
|
||||
private String restrictionDescription;
|
||||
/**
|
||||
* 封禁截止日期
|
||||
*/
|
||||
@JSONField(name = "RestrictionDeadline")
|
||||
private String RestrictionDeadline2;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.resp.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-05-14 14:39
|
||||
*/
|
||||
@Data
|
||||
public class VenueList {
|
||||
|
||||
private Integer placeId;
|
||||
|
||||
private String placeName;
|
||||
|
||||
private List<SitePositionList> sitePosition;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xiang.common.pojo.jntyzx.zlb;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-07 15:44
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ZlbCaptcha {
|
||||
|
||||
private String type;
|
||||
private String backgroundImage;
|
||||
private String templateImage;
|
||||
private String backgroundImageTag;
|
||||
private String templateImageTag;
|
||||
private Integer backgroundImageWidth;
|
||||
private Integer backgroundImageHeight;
|
||||
private Integer templateImageWidth;
|
||||
private Integer templateImageHeight;
|
||||
private String data;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xiang.common.pojo.jntyzx.zlb;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-07 15:44
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ZlbCaptchaResp {
|
||||
private String id;
|
||||
private ZlbCaptcha captcha;
|
||||
}
|
||||
@@ -20,6 +20,8 @@ public class ZlbTokenInfo {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Integer loginInfoId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,8 @@ public class ZlbUserInfo {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Integer loginInfoId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
|
||||
@@ -9,10 +9,12 @@ import com.xiang.common.pojo.code.YcCodeDataResp;
|
||||
import com.xiang.common.pojo.code.YcCodeRequest;
|
||||
import com.xiang.common.utils.HttpService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@@ -42,14 +44,35 @@ public class CodeServiceImpl implements ICodeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String codeResolve(String image, String extra) {
|
||||
YcCodeBaseResponse<YcCodeDataResp> resp = baseCodeResolve(YcCodeTypeEnum.YC_6246.getType(), image, extra);
|
||||
if (Objects.isNull(resp)) {
|
||||
public List<String> codeResolve(String image, String templateImage) {
|
||||
HashMap<String, String> header = Maps.newHashMap();
|
||||
header.put("Content-Type", "application/json");
|
||||
YcCodeRequest ycCodeRequest = new YcCodeRequest();
|
||||
ycCodeRequest.setImage(image);
|
||||
ycCodeRequest.setToken("9LQ1ATKVEeO8Arhq-HavXzpHvkzdZz_r7ydmqlYhp9c");
|
||||
ycCodeRequest.setLabelImage(templateImage);
|
||||
ycCodeRequest.setType(YcCodeTypeEnum.YC_310700.getType());
|
||||
|
||||
String resp = HttpService.doPost(YUN_CODE_API_URL, header, JSON.toJSONString(ycCodeRequest));
|
||||
YcCodeBaseResponse<YcCodeDataResp> response = JSON.parseObject(resp, new TypeReference<YcCodeBaseResponse<YcCodeDataResp>>() {
|
||||
});
|
||||
if (Objects.isNull(response)) {
|
||||
return null;
|
||||
}
|
||||
Integer code = resp.getCode();
|
||||
if (200 == code) {
|
||||
return resp.getData().getData();
|
||||
Integer code = response.getCode();
|
||||
if (10000 == code) {
|
||||
YcCodeDataResp data = response.getData();
|
||||
if (Objects.isNull(data)) {
|
||||
return null;
|
||||
}
|
||||
Integer dataCode = data.getCode();
|
||||
if (0 == dataCode) {
|
||||
String dataData = data.getData();
|
||||
if (StringUtils.isNotBlank(dataData)) {
|
||||
String[] split = dataData.split("\\|");
|
||||
return Arrays.asList(split);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@ import com.xiang.common.pojo.code.YcCodeBaseResponse;
|
||||
import com.xiang.common.pojo.code.YcCodeDataResp;
|
||||
import com.xiang.common.pojo.code.YcCodeRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ICodeService {
|
||||
|
||||
String templateCodeResolve(String image);
|
||||
|
||||
String codeResolve(String image, String extra);
|
||||
List<String> codeResolve(String image, String extra);
|
||||
|
||||
YcCodeBaseResponse<YcCodeDataResp> baseCodeResolve(Integer type, String image, String extra);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,11 @@ import java.util.List;
|
||||
|
||||
public interface IScheduleOpeningConfigService extends IService<ScheduleOpeningConfigDO> {
|
||||
|
||||
/**
|
||||
* 获取所有未删除的任务
|
||||
* @return
|
||||
*/
|
||||
List<ScheduleOpeningConfigDO> getAll();
|
||||
/**
|
||||
* 根据模块id和任务名称查询
|
||||
* @param moduleCode
|
||||
|
||||
@@ -7,9 +7,16 @@ import com.xiang.common.mapper.ScheduleOpeningConfigDao;
|
||||
import com.xiang.common.pojo.schedule.ScheduleOpeningConfigDO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class ScheduleOpeningConfigServiceImpl extends ServiceImpl<ScheduleOpeningConfigDao, ScheduleOpeningConfigDO> implements IScheduleOpeningConfigService {
|
||||
@Override
|
||||
public List<ScheduleOpeningConfigDO> getAll() {
|
||||
return baseMapper.selectList(Wrappers.lambdaQuery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScheduleOpeningConfigDO getConfigByModule(Integer moduleCode, String taskName) {
|
||||
LambdaQueryWrapper<ScheduleOpeningConfigDO> lqw = Wrappers.lambdaQuery();
|
||||
|
||||
253
src/main/java/com/xiang/common/utils/Base64.java
Normal file
253
src/main/java/com/xiang/common/utils/Base64.java
Normal file
@@ -0,0 +1,253 @@
|
||||
package com.xiang.common.utils;
|
||||
|
||||
/**
|
||||
* Base64工具类
|
||||
*
|
||||
* @author xiang
|
||||
*/
|
||||
public final class Base64 {
|
||||
static private final int BASELENGTH = 128;
|
||||
static private final int LOOKUPLENGTH = 64;
|
||||
static private final int TWENTYFOURBITGROUP = 24;
|
||||
static private final int EIGHTBIT = 8;
|
||||
static private final int SIXTEENBIT = 16;
|
||||
static private final int FOURBYTE = 4;
|
||||
static private final int SIGN = -128;
|
||||
static private final char PAD = '=';
|
||||
static final private byte[] base64Alphabet = new byte[BASELENGTH];
|
||||
static final private char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH];
|
||||
|
||||
static {
|
||||
for (int i = 0; i < BASELENGTH; ++i) {
|
||||
base64Alphabet[i] = -1;
|
||||
}
|
||||
for (int i = 'Z'; i >= 'A'; i--) {
|
||||
base64Alphabet[i] = (byte) (i - 'A');
|
||||
}
|
||||
for (int i = 'z'; i >= 'a'; i--) {
|
||||
base64Alphabet[i] = (byte) (i - 'a' + 26);
|
||||
}
|
||||
|
||||
for (int i = '9'; i >= '0'; i--) {
|
||||
base64Alphabet[i] = (byte) (i - '0' + 52);
|
||||
}
|
||||
|
||||
base64Alphabet['+'] = 62;
|
||||
base64Alphabet['/'] = 63;
|
||||
|
||||
for (int i = 0; i <= 25; i++) {
|
||||
lookUpBase64Alphabet[i] = (char) ('A' + i);
|
||||
}
|
||||
|
||||
for (int i = 26, j = 0; i <= 51; i++, j++) {
|
||||
lookUpBase64Alphabet[i] = (char) ('a' + j);
|
||||
}
|
||||
|
||||
for (int i = 52, j = 0; i <= 61; i++, j++) {
|
||||
lookUpBase64Alphabet[i] = (char) ('0' + j);
|
||||
}
|
||||
lookUpBase64Alphabet[62] = '+';
|
||||
lookUpBase64Alphabet[63] = '/';
|
||||
}
|
||||
|
||||
private static boolean isWhiteSpace(char octect) {
|
||||
return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9);
|
||||
}
|
||||
|
||||
private static boolean isPad(char octect) {
|
||||
return (octect == PAD);
|
||||
}
|
||||
|
||||
private static boolean isData(char octect) {
|
||||
return (octect < BASELENGTH && base64Alphabet[octect] != -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes hex octects into Base64
|
||||
*
|
||||
* @param binaryData Array containing binaryData
|
||||
* @return Encoded Base64 array
|
||||
*/
|
||||
public static String encode(byte[] binaryData) {
|
||||
if (binaryData == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int lengthDataBits = binaryData.length * EIGHTBIT;
|
||||
if (lengthDataBits == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
|
||||
int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
|
||||
int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets;
|
||||
char[] encodedData = null;
|
||||
|
||||
encodedData = new char[numberQuartet * 4];
|
||||
|
||||
byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0;
|
||||
|
||||
int encodedIndex = 0;
|
||||
int dataIndex = 0;
|
||||
|
||||
for (int i = 0; i < numberTriplets; i++) {
|
||||
b1 = binaryData[dataIndex++];
|
||||
b2 = binaryData[dataIndex++];
|
||||
b3 = binaryData[dataIndex++];
|
||||
|
||||
l = (byte) (b2 & 0x0f);
|
||||
k = (byte) (b1 & 0x03);
|
||||
|
||||
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
|
||||
byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
|
||||
byte val3 = ((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc);
|
||||
|
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
|
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)];
|
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[(l << 2) | val3];
|
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[b3 & 0x3f];
|
||||
}
|
||||
|
||||
// form integral number of 6-bit groups
|
||||
if (fewerThan24bits == EIGHTBIT) {
|
||||
b1 = binaryData[dataIndex];
|
||||
k = (byte) (b1 & 0x03);
|
||||
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
|
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
|
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4];
|
||||
encodedData[encodedIndex++] = PAD;
|
||||
encodedData[encodedIndex++] = PAD;
|
||||
} else if (fewerThan24bits == SIXTEENBIT) {
|
||||
b1 = binaryData[dataIndex];
|
||||
b2 = binaryData[dataIndex + 1];
|
||||
l = (byte) (b2 & 0x0f);
|
||||
k = (byte) (b1 & 0x03);
|
||||
|
||||
byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
|
||||
byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
|
||||
|
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[val1];
|
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[val2 | (k << 4)];
|
||||
encodedData[encodedIndex++] = lookUpBase64Alphabet[l << 2];
|
||||
encodedData[encodedIndex++] = PAD;
|
||||
}
|
||||
return new String(encodedData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes Base64 data into octects
|
||||
*
|
||||
* @param encoded string containing Base64 data
|
||||
* @return Array containind decoded data.
|
||||
*/
|
||||
public static byte[] decode(String encoded) {
|
||||
if (encoded == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
char[] base64Data = encoded.toCharArray();
|
||||
// remove white spaces
|
||||
int len = removeWhiteSpace(base64Data);
|
||||
|
||||
if (len % FOURBYTE != 0) {
|
||||
return null;// should be divisible by four
|
||||
}
|
||||
|
||||
int numberQuadruple = (len / FOURBYTE);
|
||||
|
||||
if (numberQuadruple == 0) {
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
byte[] decodedData = null;
|
||||
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
|
||||
char d1 = 0, d2 = 0, d3 = 0, d4 = 0;
|
||||
|
||||
int i = 0;
|
||||
int encodedIndex = 0;
|
||||
int dataIndex = 0;
|
||||
decodedData = new byte[(numberQuadruple) * 3];
|
||||
|
||||
for (; i < numberQuadruple - 1; i++) {
|
||||
|
||||
if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))
|
||||
|| !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++]))) {
|
||||
return null;
|
||||
} // if found "no data" just return null
|
||||
|
||||
b1 = base64Alphabet[d1];
|
||||
b2 = base64Alphabet[d2];
|
||||
b3 = base64Alphabet[d3];
|
||||
b4 = base64Alphabet[d4];
|
||||
|
||||
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
|
||||
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
|
||||
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
|
||||
}
|
||||
|
||||
if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) {
|
||||
return null;// if found "no data" just return null
|
||||
}
|
||||
|
||||
b1 = base64Alphabet[d1];
|
||||
b2 = base64Alphabet[d2];
|
||||
|
||||
d3 = base64Data[dataIndex++];
|
||||
d4 = base64Data[dataIndex++];
|
||||
if (!isData((d3)) || !isData((d4))) {// Check if they are PAD characters
|
||||
if (isPad(d3) && isPad(d4)) {
|
||||
if ((b2 & 0xf) != 0)// last 4 bits should be zero
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] tmp = new byte[i * 3 + 1];
|
||||
System.arraycopy(decodedData, 0, tmp, 0, i * 3);
|
||||
tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
|
||||
return tmp;
|
||||
} else if (!isPad(d3) && isPad(d4)) {
|
||||
b3 = base64Alphabet[d3];
|
||||
if ((b3 & 0x3) != 0)// last 2 bits should be zero
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] tmp = new byte[i * 3 + 2];
|
||||
System.arraycopy(decodedData, 0, tmp, 0, i * 3);
|
||||
tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
|
||||
tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
|
||||
return tmp;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else { // No PAD e.g 3cQl
|
||||
b3 = base64Alphabet[d3];
|
||||
b4 = base64Alphabet[d4];
|
||||
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
|
||||
decodedData[encodedIndex++] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
|
||||
decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
|
||||
|
||||
}
|
||||
return decodedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* remove WhiteSpace from MIME containing encoded Base64 data.
|
||||
*
|
||||
* @param data the byte array of base64 data (with WS)
|
||||
* @return the new length
|
||||
*/
|
||||
private static int removeWhiteSpace(char[] data) {
|
||||
if (data == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// count characters that's not whitespace
|
||||
int newSize = 0;
|
||||
int len = data.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (!isWhiteSpace(data[i])) {
|
||||
data[newSize++] = data[i];
|
||||
}
|
||||
}
|
||||
return newSize;
|
||||
}
|
||||
}
|
||||
97
src/main/java/com/xiang/common/utils/Base64ImageScaler.java
Normal file
97
src/main/java/com/xiang/common/utils/Base64ImageScaler.java
Normal file
File diff suppressed because one or more lines are too long
@@ -3,6 +3,8 @@ package com.xiang.common.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.xiang.common.enums.DateFormatEnum;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
@@ -11,6 +13,8 @@ import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -22,72 +26,20 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class DateUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DateUtils.class);
|
||||
|
||||
/**
|
||||
* 构造函数.
|
||||
*/
|
||||
public void DateUtil() {
|
||||
throw new RuntimeException("this is a util class,can not instance!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ASCM_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT_YMD = "yyyy-MM-dd";
|
||||
public static final String ENUM_FORMAT_YMD_1 = "yyyyMMdd";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT_YMDS = "yyyy-MM-dd HH:mm:ss.S";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT_SLASH = "yyyy/MM/dd HH:mm:ss";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT_YMDS_SLASH = "yyyy/MM/dd HH:mm:ss.S";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String LEVEL_DAY = "day"; // 粒度级别
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String LEVEL_HOUR = "hour";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String LEVEL_MINUTE = "minute";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String LEVEL_SECOND = "second";
|
||||
|
||||
/**
|
||||
* 日期特殊字符对应.
|
||||
*/
|
||||
private static Map<String, String> mapSign = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 使用ThreadLocal保证SimpleDateFormat线程安全.
|
||||
*/
|
||||
private static ThreadLocal<Map<String, SimpleDateFormat>> threadLocalDateFormat = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
@@ -134,6 +86,11 @@ public class DateUtils {
|
||||
return convertToChinese(dayOfWeek);
|
||||
}
|
||||
|
||||
public static String getWeekDay(LocalDate date) {
|
||||
DayOfWeek dayOfWeek = date.getDayOfWeek();
|
||||
return convertToChinese(dayOfWeek);
|
||||
}
|
||||
|
||||
private static String convertToChinese(DayOfWeek dayOfWeek) {
|
||||
switch (dayOfWeek) {
|
||||
case MONDAY:
|
||||
@@ -603,4 +560,56 @@ public class DateUtils {
|
||||
public static Date setModifiedDate(String key, Date date) {
|
||||
return modifiedDate.put(key, date);
|
||||
}
|
||||
|
||||
public static LocalDateTime getDateTimeFromStr(String dateStr) {
|
||||
return getDateTimeFromStr(dateStr, "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
public static LocalDateTime getDateTimeFromStr(String dateStr, String pattern) {
|
||||
return LocalDateTime.parse(dateStr, DateTimeFormatter.ofPattern(pattern));
|
||||
}
|
||||
|
||||
public static LocalDate getDateFromStr(String dataStr) {
|
||||
return getDateFromStr(dataStr, "yyyy-MM-dd");
|
||||
}
|
||||
|
||||
public static LocalDate getDateFromStr(String dataStr, String pattern) {
|
||||
return LocalDate.parse(dataStr, DateTimeFormatter.ofPattern(pattern));
|
||||
}
|
||||
|
||||
public static String getDateFromDate(LocalDate date) {
|
||||
return getDateFromDate(date, "yyyy-MM-dd");
|
||||
}
|
||||
|
||||
public static String getDateFromDate(LocalDate date, String pattern) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
return date.format(formatter);
|
||||
}
|
||||
|
||||
public static String getDateTimeFromDateTime(LocalDateTime dateTime) {
|
||||
return getDateTimeFromDateTime(dateTime, "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
public static String getDateTimeFromDateTime(LocalDateTime dateTime, String pattern) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
return dateTime.format(formatter);
|
||||
}
|
||||
|
||||
public static LocalDateTime getTimeFromStr(String date, String time) {
|
||||
String dateTimeStr = date + " " + time;
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
return LocalDateTime.parse(dateTimeStr, formatter);
|
||||
}
|
||||
|
||||
public static Boolean validWeekTime() {
|
||||
if (!Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SATURDAY) && !Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SUNDAY)) {
|
||||
LocalTime now = LocalTime.now();
|
||||
boolean inMorning = now.isAfter(LocalTime.of(9, 29)) && now.isBefore(LocalTime.of(11, 31));
|
||||
boolean inAfternoon = now.isAfter(LocalTime.of(12, 59)) && now.isBefore(LocalTime.of(15, 1));
|
||||
return !inAfternoon && !inMorning ? true : false;
|
||||
} else {
|
||||
logger.info("当前时间为:{}", LocalDateTime.now());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class HttpService {
|
||||
CloseableHttpResponse response = null;
|
||||
String result = "";
|
||||
try {
|
||||
log.info("HTTP请求,请求地址===>{}, 请求头===>{}, 请求参数===>{}", url, JSON.toJSONString(header), jsonParams);
|
||||
log.debug("HTTP请求,请求地址===>{}, 请求头===>{}, 请求参数===>{}", url, JSON.toJSONString(header), jsonParams);
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
httpPost.addHeader("Content-Type", "application/json");
|
||||
// 创建请求内容
|
||||
@@ -88,7 +88,7 @@ public class HttpService {
|
||||
}
|
||||
response = httpClient.execute(httpPost);
|
||||
result = EntityUtils.toString(response.getEntity(), "utf-8");
|
||||
log.info("【POST请求】 请求地址===>{}, 响应结果==={}", url, result);
|
||||
log.debug("【POST请求】 请求地址===>{}, 响应结果==={}", url, result);
|
||||
} catch (Exception e) {
|
||||
log.error("doPost异常", e);
|
||||
} finally {
|
||||
@@ -117,10 +117,10 @@ public class HttpService {
|
||||
httpGet.setHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
log.info("doGet请求:请求头:{},请求地址:{}", header, url + request);
|
||||
log.debug("doGet请求:请求头:{},请求地址:{}", header, url + request);
|
||||
response = httpClient.execute(httpGet);
|
||||
result = EntityUtils.toString(response.getEntity(), "utf-8");
|
||||
log.info("【GET请求】, 请求地址===>{}, 响应结果===>{}", url + request, result);
|
||||
log.debug("【GET请求】, 请求地址===>{}, 响应结果===>{}", url + request, result);
|
||||
} catch (Exception e) {
|
||||
log.error("doGet异常:", e);
|
||||
} finally {
|
||||
|
||||
68
src/main/java/com/xiang/common/utils/ImageUtils.java
Normal file
68
src/main/java/com/xiang/common/utils/ImageUtils.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.xiang.common.utils;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-08 08:56
|
||||
*/
|
||||
public class ImageUtils {
|
||||
/**
|
||||
* 将 Base64 图片写入文件
|
||||
* @param base64String Base64 编码的图片字符串
|
||||
* @param outputPath 输出文件路径
|
||||
*/
|
||||
public static void saveBase64Image(String base64String, String outputPath) {
|
||||
try {
|
||||
// 处理可能包含前缀的 Base64(如 data:image/png;base64,)
|
||||
String base64Data = extractBase64Data(base64String);
|
||||
|
||||
// 解码 Base64
|
||||
byte[] imageBytes = Base64.getDecoder().decode(base64Data);
|
||||
|
||||
// 写入文件
|
||||
try (FileOutputStream fos = new FileOutputStream(outputPath)) {
|
||||
fos.write(imageBytes);
|
||||
}
|
||||
|
||||
System.out.println("图片已保存至: " + outputPath);
|
||||
|
||||
} catch (IllegalArgumentException e) {
|
||||
System.err.println("Base64 解码失败: " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
System.err.println("文件写入失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 提取纯 Base64 数据(去除前缀)
|
||||
*/
|
||||
private static String extractBase64Data(String base64String) {
|
||||
if (base64String == null || base64String.isEmpty()) {
|
||||
throw new IllegalArgumentException("Base64 字符串不能为空");
|
||||
}
|
||||
|
||||
// 检查是否包含 data:image/xxx;base64, 前缀
|
||||
if (base64String.contains(",")) {
|
||||
return base64String.split(",", 2)[1];
|
||||
}
|
||||
|
||||
return base64String;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 Base64 字符串中获取图片类型
|
||||
*/
|
||||
public static String getImageType(String base64String) {
|
||||
if (base64String.startsWith("data:image/")) {
|
||||
String type = base64String.substring(11, base64String.indexOf(";"));
|
||||
return type; // 返回 png, jpeg, gif 等
|
||||
}
|
||||
return "png"; // 默认类型
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
18
src/main/java/com/xiang/common/utils/JsonUtils.java
Normal file
18
src/main/java/com/xiang/common/utils/JsonUtils.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.xiang.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-07-25 15:58
|
||||
*/
|
||||
public class JsonUtils {
|
||||
public static String toJsonString(Object obj) {
|
||||
return JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue);
|
||||
}
|
||||
|
||||
public static <T> T parse(String json, Class<T> clazz) {
|
||||
return JSON.parseObject(json, clazz);
|
||||
}
|
||||
}
|
||||
198
src/main/java/com/xiang/common/utils/TrajectoryUtil.java
Normal file
198
src/main/java/com/xiang/common/utils/TrajectoryUtil.java
Normal file
@@ -0,0 +1,198 @@
|
||||
package com.xiang.common.utils;
|
||||
|
||||
import com.xiang.common.pojo.TrackPoint;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 鼠标轨迹生成工具类 - 开箱即用
|
||||
*
|
||||
* 使用方法:
|
||||
* 1. 直接调用 TrajectoryUtil.generate(起点, 终点, 时长, 点数)
|
||||
* 2. 或使用预设的购物流程 TrajectoryUtil.shoppingFlow()
|
||||
*/
|
||||
public class TrajectoryUtil {
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
// ==================== 核心方法 ====================
|
||||
|
||||
/**
|
||||
* 生成两点之间的移动轨迹
|
||||
* @param fromX 起点X
|
||||
* @param fromY 起点Y
|
||||
* @param toX 终点X
|
||||
* @param toY 终点Y
|
||||
* @param duration 移动时长(毫秒)
|
||||
* @param pointCount 生成点数
|
||||
* @return 轨迹点列表
|
||||
*/
|
||||
public static List<TrackPoint> generateMove(int fromX, int fromY, int toX, int toY, int start ,int duration, int pointCount) {
|
||||
List<TrackPoint> points = new ArrayList<>();
|
||||
|
||||
// 随机控制点(让路径弯曲)
|
||||
int cx = (fromX + toX) / 2 + (random.nextInt(100) - 50);
|
||||
int cy = (fromY + toY) / 2 + (random.nextInt(100) - 50);
|
||||
|
||||
for (int i = 0; i <= pointCount; i++) {
|
||||
double t = (double) i / pointCount;
|
||||
// 缓动:开始慢 -> 中间快 -> 结束慢
|
||||
t = easeInOutCubic(t);
|
||||
|
||||
// 贝塞尔曲线
|
||||
int x = (int)((1-t)*(1-t)*fromX + 2*(1-t)*t*cx + t*t*toX);
|
||||
int y = (int)((1-t)*(1-t)*fromY + 2*(1-t)*t*cy + t*t*toY);
|
||||
|
||||
// 随机抖动
|
||||
x += random.nextInt(5) - 2;
|
||||
y += random.nextInt(5) - 2;
|
||||
|
||||
int time = start + (int)(t * duration);
|
||||
points.add(new TrackPoint(x, y, time, "move"));
|
||||
}
|
||||
|
||||
// 确保终点精确
|
||||
points.get(points.size()-1).x = toX;
|
||||
points.get(points.size()-1).y = toY;
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成点击动作
|
||||
* @param x 点击X坐标
|
||||
* @param y 点击Y坐标
|
||||
* @param startTime 开始时间(毫秒)
|
||||
* @return 轨迹点列表
|
||||
*/
|
||||
public static List<TrackPoint> generateClick(int x, int y, int startTime) {
|
||||
List<TrackPoint> points = new ArrayList<>();
|
||||
int currentTime = startTime;
|
||||
|
||||
// 思考时间
|
||||
currentTime += 100 + random.nextInt(400);
|
||||
points.add(new TrackPoint(x, y, currentTime, "hover"));
|
||||
|
||||
// 微调对准
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int offsetX = x + (random.nextInt(6) - 3);
|
||||
int offsetY = y + (random.nextInt(6) - 3);
|
||||
currentTime += 30 + random.nextInt(50);
|
||||
points.add(new TrackPoint(offsetX, offsetY, currentTime, "move"));
|
||||
}
|
||||
|
||||
// 点击
|
||||
currentTime += 50 + random.nextInt(100);
|
||||
points.add(new TrackPoint(x, y, currentTime, "click"));
|
||||
|
||||
// 点击后停留
|
||||
currentTime += 80 + random.nextInt(150);
|
||||
points.add(new TrackPoint(x, y, currentTime, "hover"));
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机取点(只返回一个点位)
|
||||
* @param fromX 起点X
|
||||
* @param fromY 起点Y
|
||||
* @param toX 终点X
|
||||
* @param toY 终点Y
|
||||
* @return 随机点位
|
||||
*/
|
||||
public static Point getRandomPoint(int fromX, int fromY, int toX, int toY) {
|
||||
double ratio = random.nextDouble();
|
||||
int x = fromX + (int)((toX - fromX) * ratio);
|
||||
int y = fromY + (int)((toY - fromY) * ratio);
|
||||
|
||||
// 添加随机偏移
|
||||
if (random.nextBoolean()) {
|
||||
x += random.nextInt(30) - 15;
|
||||
y += random.nextInt(30) - 15;
|
||||
}
|
||||
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成多个随机点
|
||||
* @param fromX 起点X
|
||||
* @param fromY 起点Y
|
||||
* @param toX 终点X
|
||||
* @param toY 终点Y
|
||||
* @param count 生成数量
|
||||
* @return 随机点位列表
|
||||
*/
|
||||
public static List<Point> getRandomPoints(int fromX, int fromY, int toX, int toY, int count) {
|
||||
List<Point> points = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
points.add(getRandomPoint(fromX, fromY, toX, toY));
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
// ==================== 工具方法 ====================
|
||||
|
||||
/**
|
||||
* 缓动函数
|
||||
*/
|
||||
private static double easeInOutCubic(double t) {
|
||||
return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出为JSON字符串
|
||||
*/
|
||||
public static String toJson(List<TrackPoint> points) {
|
||||
StringBuilder sb = new StringBuilder("[\n");
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
sb.append(" ").append(points.get(i).toString());
|
||||
if (i < points.size() - 1) sb.append(",");
|
||||
sb.append("\n");
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出为紧凑JSON(无换行)
|
||||
*/
|
||||
public static String toJsonCompact(List<TrackPoint> points) {
|
||||
StringBuilder sb = new StringBuilder("[");
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
sb.append(points.get(i).toString());
|
||||
if (i < points.size() - 1) sb.append(",");
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印轨迹信息
|
||||
*/
|
||||
public static void printInfo(List<TrackPoint> points) {
|
||||
if (points.isEmpty()) {
|
||||
System.out.println("轨迹为空");
|
||||
return;
|
||||
}
|
||||
|
||||
int clickCount = 0;
|
||||
int moveCount = 0;
|
||||
for (TrackPoint p : points) {
|
||||
if ("click".equals(p.type)) clickCount++;
|
||||
if ("move".equals(p.type)) moveCount++;
|
||||
}
|
||||
|
||||
System.out.println("=== 轨迹信息 ===");
|
||||
System.out.println("总点数: " + points.size());
|
||||
System.out.println("移动点: " + moveCount);
|
||||
System.out.println("点击点: " + clickCount);
|
||||
System.out.println("总时长: " + points.get(points.size()-1).t + "ms");
|
||||
System.out.println("起始位置: (" + points.get(0).x + "," + points.get(0).y + ")");
|
||||
System.out.println("结束位置: (" + points.get(points.size()-1).x + "," + points.get(points.size()-1).y + ")");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
package com.xiang.common.utils;
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbOrderInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ZLB 验证码轨迹调试器。
|
||||
* 输入原始图片和轨迹点,输出控制台预览与带标注调试图。
|
||||
*/
|
||||
@Slf4j
|
||||
public class ZlbCaptchaTrackDebugger {
|
||||
|
||||
private static final DateTimeFormatter FILE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss_SSS");
|
||||
private static final int DEFAULT_CONSOLE_WIDTH = 84;
|
||||
private static final int DEFAULT_CONSOLE_HEIGHT = 24;
|
||||
private static final Path OUTPUT_DIR = Paths.get("logs", "script", "track-debug");
|
||||
private static final String DEFAULT_REQUEST_ID = "debug-demo";
|
||||
private static final String DEFAULT_COORDINATE_TEXT = "226,89|76,62|125,101|26,114";
|
||||
private static final Path DEFAULT_IMAGE_FILE = Paths.get("src", "main", "resources", "image.txt");
|
||||
|
||||
private ZlbCaptchaTrackDebugger() {
|
||||
}
|
||||
|
||||
public static DebugResult debug(String base64Image,
|
||||
List<String> rawTrackList,
|
||||
List<ZlbOrderInfo.ZlbData.TrackList> generatedTrackList,
|
||||
String requestId) {
|
||||
try {
|
||||
BufferedImage originalImage = decodeBase64Image(base64Image);
|
||||
List<Point> rawPoints = parseRawTrackList(rawTrackList);
|
||||
String consolePreview = buildConsolePreview(originalImage, rawPoints, generatedTrackList, requestId);
|
||||
String debugImagePath = exportDebugImage(originalImage, rawPoints, generatedTrackList, requestId);
|
||||
return new DebugResult(consolePreview, debugImagePath);
|
||||
} catch (Exception e) {
|
||||
log.warn("生成 ZLB 验证码轨迹调试信息失败", e);
|
||||
return new DebugResult(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static ExecutionResult execute(String imageBase64, String coordinateText, String requestId) {
|
||||
List<String> rawTrackList = ZlbCaptchaTrackUtil.parseCoordinateText(coordinateText);
|
||||
List<ZlbOrderInfo.ZlbData.TrackList> generatedTrackList = ZlbCaptchaTrackUtil.generateBezierTrackList(rawTrackList);
|
||||
DebugResult debugResult = debug(imageBase64, rawTrackList, generatedTrackList, requestId);
|
||||
return new ExecutionResult(generatedTrackList, debugResult.getConsolePreview(), debugResult.getDebugImagePath());
|
||||
}
|
||||
|
||||
public static ExecutionResult execute(String imageBase64, List<String> coordinateText, String requestId) {
|
||||
List<String> rawTrackList = coordinateText;
|
||||
List<ZlbOrderInfo.ZlbData.TrackList> generatedTrackList = ZlbCaptchaTrackUtil.generateBezierTrackList(rawTrackList);
|
||||
DebugResult debugResult = debug(imageBase64, rawTrackList, generatedTrackList, requestId);
|
||||
return new ExecutionResult(generatedTrackList, debugResult.getConsolePreview(), debugResult.getDebugImagePath());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 0) {
|
||||
runLocalSample();
|
||||
return;
|
||||
}
|
||||
if (args.length < 3) {
|
||||
System.out.println("Usage: ZlbCaptchaTrackDebugger <requestId> <coordinateText> <imageBase64>");
|
||||
return;
|
||||
}
|
||||
ExecutionResult result = execute(args[2], args[1], args[0]);
|
||||
System.out.println("trackList=" + result.getTrackListJson());
|
||||
if (result.getConsolePreview() != null) {
|
||||
System.out.println(result.getConsolePreview());
|
||||
}
|
||||
if (result.getDebugImagePath() != null) {
|
||||
System.out.println("debugImagePath=" + result.getDebugImagePath());
|
||||
}
|
||||
}
|
||||
|
||||
public static void runLocalSample() {
|
||||
try {
|
||||
String imageBase64 = loadDefaultImageBase64();
|
||||
ImageUtils.saveBase64Image(imageBase64, OUTPUT_DIR.toFile() + "image.jpeg");
|
||||
ExecutionResult result = execute(imageBase64, DEFAULT_COORDINATE_TEXT, DEFAULT_REQUEST_ID);
|
||||
System.out.println("trackList=" + result.getTrackListJson());
|
||||
if (result.getConsolePreview() != null) {
|
||||
System.out.println(result.getConsolePreview());
|
||||
}
|
||||
if (result.getDebugImagePath() != null) {
|
||||
System.out.println("debugImagePath=" + result.getDebugImagePath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("运行本地样例失败,请先把 image base64 写入 " + DEFAULT_IMAGE_FILE.toAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String loadDefaultImageBase64() throws IOException {
|
||||
return new String(Files.readAllBytes(DEFAULT_IMAGE_FILE), StandardCharsets.UTF_8).trim();
|
||||
}
|
||||
|
||||
private static BufferedImage decodeBase64Image(String base64Image) throws IOException {
|
||||
String base64Data = base64Image;
|
||||
if (base64Image != null && base64Image.contains(",")) {
|
||||
base64Data = base64Image.substring(base64Image.indexOf(',') + 1);
|
||||
}
|
||||
byte[] imageBytes = Base64.getDecoder().decode(base64Data);
|
||||
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(imageBytes)) {
|
||||
BufferedImage image = ImageIO.read(inputStream);
|
||||
if (image == null) {
|
||||
throw new IOException("base64 图片解码结果为空");
|
||||
}
|
||||
return image;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Point> parseRawTrackList(List<String> rawTrackList) {
|
||||
if (rawTrackList == null || rawTrackList.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Point> points = new ArrayList<>(rawTrackList.size());
|
||||
for (String item : rawTrackList) {
|
||||
if (item == null || item.trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
String[] split = item.split(",");
|
||||
if (split.length < 2) {
|
||||
continue;
|
||||
}
|
||||
points.add(new Point(Integer.parseInt(split[0].trim()), Integer.parseInt(split[1].trim())));
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
private static String buildConsolePreview(BufferedImage originalImage,
|
||||
List<Point> rawPoints,
|
||||
List<ZlbOrderInfo.ZlbData.TrackList> generatedTrackList,
|
||||
String requestId) {
|
||||
int width = originalImage.getWidth();
|
||||
int height = originalImage.getHeight();
|
||||
int consoleWidth = Math.min(DEFAULT_CONSOLE_WIDTH, Math.max(24, width));
|
||||
int consoleHeight = Math.min(DEFAULT_CONSOLE_HEIGHT, Math.max(12, (int) Math.round((double) height / width * consoleWidth * 0.5d)));
|
||||
|
||||
char[][] canvas = new char[consoleHeight][consoleWidth];
|
||||
for (int row = 0; row < consoleHeight; row++) {
|
||||
for (int col = 0; col < consoleWidth; col++) {
|
||||
canvas[row][col] = '.';
|
||||
}
|
||||
}
|
||||
|
||||
overlayRawPoints(canvas, rawPoints, width, height);
|
||||
overlayGeneratedTrack(canvas, generatedTrackList, width, height);
|
||||
|
||||
StringBuilder preview = new StringBuilder();
|
||||
preview.append('\n');
|
||||
preview.append("===== ZLB CAPTCHA DEBUG =====").append('\n');
|
||||
preview.append("requestId=").append(sanitizeFileName(requestId))
|
||||
.append(", image=").append(width).append("x").append(height)
|
||||
.append(", rawPoints=").append(rawPoints.size())
|
||||
.append(", generatedPoints=").append(generatedTrackList == null ? 0 : generatedTrackList.size())
|
||||
.append('\n');
|
||||
preview.append("rawPoints=").append(buildRawPointSummary(rawPoints)).append('\n');
|
||||
preview.append("generatedTrack=").append(buildTrackSummary(generatedTrackList)).append('\n');
|
||||
preview.append("grid: R=raw point, C=click, M=move, B=overlap, .=empty").append('\n');
|
||||
for (char[] chars : canvas) {
|
||||
preview.append(chars).append('\n');
|
||||
}
|
||||
preview.append("================================").append('\n');
|
||||
return preview.toString();
|
||||
}
|
||||
|
||||
private static String exportDebugImage(BufferedImage originalImage,
|
||||
List<Point> rawPoints,
|
||||
List<ZlbOrderInfo.ZlbData.TrackList> generatedTrackList,
|
||||
String requestId) throws IOException {
|
||||
BufferedImage debugImage = new BufferedImage(
|
||||
originalImage.getWidth(),
|
||||
originalImage.getHeight(),
|
||||
BufferedImage.TYPE_INT_ARGB
|
||||
);
|
||||
Graphics2D graphics = debugImage.createGraphics();
|
||||
try {
|
||||
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
graphics.drawImage(originalImage, 0, 0, null);
|
||||
drawGeneratedTrack(graphics, generatedTrackList);
|
||||
drawRawPoints(graphics, rawPoints);
|
||||
drawLegend(graphics);
|
||||
} finally {
|
||||
graphics.dispose();
|
||||
}
|
||||
|
||||
Files.createDirectories(OUTPUT_DIR);
|
||||
String fileName = String.format(
|
||||
"zlb_track_%s_%s.png",
|
||||
sanitizeFileName(requestId),
|
||||
FILE_TIME_FORMATTER.format(LocalDateTime.now())
|
||||
);
|
||||
Path outputPath = OUTPUT_DIR.resolve(fileName).toAbsolutePath();
|
||||
ImageIO.write(debugImage, "png", outputPath.toFile());
|
||||
return outputPath.toString();
|
||||
}
|
||||
|
||||
private static void overlayRawPoints(char[][] canvas, List<Point> rawPoints, int width, int height) {
|
||||
for (Point rawPoint : rawPoints) {
|
||||
int col = scaleToConsole(rawPoint.x, width, canvas[0].length);
|
||||
int row = scaleToConsole(rawPoint.y, height, canvas.length);
|
||||
paintOverlay(canvas, row, col, 'R');
|
||||
}
|
||||
}
|
||||
|
||||
private static void overlayGeneratedTrack(char[][] canvas,
|
||||
List<ZlbOrderInfo.ZlbData.TrackList> generatedTrackList,
|
||||
int width,
|
||||
int height) {
|
||||
if (generatedTrackList == null) {
|
||||
return;
|
||||
}
|
||||
for (ZlbOrderInfo.ZlbData.TrackList trackPoint : generatedTrackList) {
|
||||
int col = scaleToConsole(trackPoint.getX(), width, canvas[0].length);
|
||||
int row = scaleToConsole(trackPoint.getY(), height, canvas.length);
|
||||
char mark = "click".equalsIgnoreCase(trackPoint.getType()) ? 'C' : 'M';
|
||||
paintOverlay(canvas, row, col, mark);
|
||||
}
|
||||
}
|
||||
|
||||
private static void paintOverlay(char[][] canvas, int row, int col, char mark) {
|
||||
char current = canvas[row][col];
|
||||
if (current == 'R' || current == 'C' || current == 'M' || current == 'B') {
|
||||
canvas[row][col] = current == mark ? current : 'B';
|
||||
return;
|
||||
}
|
||||
canvas[row][col] = mark;
|
||||
}
|
||||
|
||||
private static int scaleToConsole(int value, int originalSize, int consoleSize) {
|
||||
if (originalSize <= 1) {
|
||||
return 0;
|
||||
}
|
||||
int scaled = (int) Math.round(value * (consoleSize - 1d) / (originalSize - 1d));
|
||||
return Math.max(0, Math.min(consoleSize - 1, scaled));
|
||||
}
|
||||
|
||||
private static String buildTrackSummary(List<ZlbOrderInfo.ZlbData.TrackList> generatedTrackList) {
|
||||
if (generatedTrackList == null || generatedTrackList.isEmpty()) {
|
||||
return "[]";
|
||||
}
|
||||
StringBuilder summary = new StringBuilder("[");
|
||||
for (int i = 0; i < generatedTrackList.size(); i++) {
|
||||
ZlbOrderInfo.ZlbData.TrackList trackPoint = generatedTrackList.get(i);
|
||||
if (i > 0) {
|
||||
summary.append(", ");
|
||||
}
|
||||
summary.append("{x=").append(trackPoint.getX())
|
||||
.append(", y=").append(trackPoint.getY())
|
||||
.append(", type=").append(trackPoint.getType())
|
||||
.append(", t=").append(trackPoint.getT())
|
||||
.append('}');
|
||||
}
|
||||
summary.append(']');
|
||||
return summary.toString();
|
||||
}
|
||||
|
||||
private static String buildRawPointSummary(List<Point> rawPoints) {
|
||||
if (rawPoints == null || rawPoints.isEmpty()) {
|
||||
return "[]";
|
||||
}
|
||||
StringBuilder summary = new StringBuilder("[");
|
||||
for (int i = 0; i < rawPoints.size(); i++) {
|
||||
Point point = rawPoints.get(i);
|
||||
if (i > 0) {
|
||||
summary.append(", ");
|
||||
}
|
||||
summary.append("P").append(i)
|
||||
.append("{x=").append(point.x)
|
||||
.append(", y=").append(point.y)
|
||||
.append('}');
|
||||
}
|
||||
summary.append(']');
|
||||
return summary.toString();
|
||||
}
|
||||
|
||||
private static void drawRawPoints(Graphics2D graphics, List<Point> rawPoints) {
|
||||
graphics.setFont(new Font("SansSerif", Font.BOLD, 13));
|
||||
graphics.setStroke(new BasicStroke(2.5f));
|
||||
for (int i = 0; i < rawPoints.size(); i++) {
|
||||
Point point = rawPoints.get(i);
|
||||
graphics.setColor(new Color(30, 144, 255, 210));
|
||||
graphics.drawOval(point.x - 8, point.y - 8, 16, 16);
|
||||
graphics.setColor(Color.WHITE);
|
||||
graphics.drawString("P" + i, point.x + 8, point.y - 8);
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawGeneratedTrack(Graphics2D graphics, List<ZlbOrderInfo.ZlbData.TrackList> generatedTrackList) {
|
||||
if (generatedTrackList == null || generatedTrackList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
graphics.setFont(new Font("SansSerif", Font.PLAIN, 12));
|
||||
graphics.setStroke(new BasicStroke(2.5f));
|
||||
for (int i = 0; i < generatedTrackList.size(); i++) {
|
||||
ZlbOrderInfo.ZlbData.TrackList current = generatedTrackList.get(i);
|
||||
if (i > 0) {
|
||||
ZlbOrderInfo.ZlbData.TrackList previous = generatedTrackList.get(i - 1);
|
||||
graphics.setColor(new Color(255, 99, 71, 180));
|
||||
graphics.drawLine(previous.getX(), previous.getY(), current.getX(), current.getY());
|
||||
}
|
||||
Color pointColor = "click".equalsIgnoreCase(current.getType())
|
||||
? new Color(220, 20, 60, 220)
|
||||
: new Color(255, 165, 0, 220);
|
||||
graphics.setColor(pointColor);
|
||||
graphics.fillOval(current.getX() - 5, current.getY() - 5, 10, 10);
|
||||
graphics.setColor(Color.WHITE);
|
||||
graphics.drawOval(current.getX() - 5, current.getY() - 5, 10, 10);
|
||||
// graphics.drawString(current.getType() + "(" + current.getT() + ")", current.getX() + 6, current.getY() + 16);
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawLegend(Graphics2D graphics) {
|
||||
int boxX = 12;
|
||||
int boxY = 12;
|
||||
int boxWidth = 250;
|
||||
int boxHeight = 62;
|
||||
// graphics.setColor(new Color(0, 0, 0, 135));
|
||||
// graphics.fillRoundRect(boxX, boxY, boxWidth, boxHeight, 12, 12);
|
||||
// graphics.setColor(Color.WHITE);
|
||||
// graphics.setFont(new Font("SansSerif", Font.BOLD, 13));
|
||||
// graphics.drawString("Blue: raw points", boxX + 12, boxY + 22);
|
||||
// graphics.drawString("Red: click track", boxX + 12, boxY + 40);
|
||||
// graphics.drawString("Orange: move track", boxX + 12, boxY + 58);
|
||||
}
|
||||
|
||||
private static String sanitizeFileName(String value) {
|
||||
if (value == null || value.trim().isEmpty()) {
|
||||
return "unknown";
|
||||
}
|
||||
return value.replaceAll("[^a-zA-Z0-9_-]", "_");
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static class DebugResult {
|
||||
private String consolePreview;
|
||||
private String debugImagePath;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static class ExecutionResult {
|
||||
private List<ZlbOrderInfo.ZlbData.TrackList> trackList;
|
||||
private String consolePreview;
|
||||
private String debugImagePath;
|
||||
|
||||
public String getTrackListJson() {
|
||||
return com.alibaba.fastjson2.JSON.toJSONString(trackList);
|
||||
}
|
||||
}
|
||||
}
|
||||
120
src/main/java/com/xiang/common/utils/ZlbCaptchaTrackUtil.java
Normal file
120
src/main/java/com/xiang/common/utils/ZlbCaptchaTrackUtil.java
Normal file
@@ -0,0 +1,120 @@
|
||||
package com.xiang.common.utils;
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbOrderInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* 浙里办验证码轨迹生成工具。
|
||||
*/
|
||||
public class ZlbCaptchaTrackUtil {
|
||||
|
||||
private ZlbCaptchaTrackUtil() {
|
||||
}
|
||||
|
||||
public static List<ZlbOrderInfo.ZlbData.TrackList> generateBezierTrackList(List<String> trackList) {
|
||||
List<ZlbOrderInfo.ZlbData.TrackList> result = new ArrayList<>();
|
||||
if (trackList == null || trackList.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (int i = 0; i < trackList.size(); i++) {
|
||||
int[] currentPoint = parseTrackCoordinate(trackList.get(i));
|
||||
int clickTime = result.isEmpty()
|
||||
? randomBetween(1800, 2200)
|
||||
: result.get(result.size() - 1).getT() + randomBetween(25, 60);
|
||||
result.add(buildTrackPoint(currentPoint[0], currentPoint[1], clickTime, "click"));
|
||||
|
||||
if (i < trackList.size() - 1) {
|
||||
int[] nextPoint = parseTrackCoordinate(trackList.get(i + 1));
|
||||
int moveStartTime = result.get(result.size() - 1).getT();
|
||||
int moveDuration = randomBetween(800, 1200);
|
||||
List<int[]> movePoints = buildBezierMovePoints(currentPoint[0], currentPoint[1], nextPoint[0], nextPoint[1]);
|
||||
// for (int moveIndex = 0; moveIndex < movePoints.size(); moveIndex++) {
|
||||
// int[] movePoint = movePoints.get(moveIndex);
|
||||
// int moveTime = moveStartTime + (int) Math.round((double) moveDuration * (moveIndex + 1) / (movePoints.size() + 1));
|
||||
// result.add(buildTrackPoint(movePoint[0], movePoint[1], moveTime, "move"));
|
||||
// }
|
||||
int[] movePoint = movePoints.get(movePoints.size() / 2);
|
||||
int moveTime = moveStartTime + randomBetween(800, 1200);
|
||||
result.add(buildTrackPoint(movePoint[0], movePoint[1], moveTime, "move"));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<String> parseCoordinateText(String coordinateText) {
|
||||
if (coordinateText == null || coordinateText.trim().isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String normalized = coordinateText.replace("\n", "|").replace(";", "|");
|
||||
String[] parts = normalized.split("\\|");
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String part : parts) {
|
||||
if (part != null && !part.trim().isEmpty()) {
|
||||
result.add(part.trim());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int[] parseTrackCoordinate(String track) {
|
||||
String[] coordinateArr = track.split(",");
|
||||
return new int[]{
|
||||
Integer.parseInt(coordinateArr[0].trim()),
|
||||
Integer.parseInt(coordinateArr[1].trim())
|
||||
};
|
||||
}
|
||||
|
||||
private static List<int[]> buildBezierMovePoints(int fromX, int fromY, int toX, int toY) {
|
||||
int movePointCount = randomBetween(3, 5);
|
||||
double dx = toX - fromX;
|
||||
double dy = toY - fromY;
|
||||
double distance = Math.max(1d, Math.hypot(dx, dy));
|
||||
double normalX = -dy / distance;
|
||||
double normalY = dx / distance;
|
||||
double direction = ThreadLocalRandom.current().nextBoolean() ? 1d : -1d;
|
||||
double offset = Math.min(28d, Math.max(6d, distance * ThreadLocalRandom.current().nextDouble(0.08d, 0.22d))) * direction;
|
||||
double controlX = (fromX + toX) / 2d + normalX * offset;
|
||||
double controlY = (fromY + toY) / 2d + normalY * offset;
|
||||
|
||||
List<int[]> movePoints = new ArrayList<>(movePointCount);
|
||||
for (int i = 1; i <= movePointCount; i++) {
|
||||
double progress = easeInOutCubic((double) i / (movePointCount + 1));
|
||||
int x = (int) Math.round(
|
||||
Math.pow(1 - progress, 2) * fromX
|
||||
+ 2 * (1 - progress) * progress * controlX
|
||||
+ Math.pow(progress, 2) * toX
|
||||
);
|
||||
int y = (int) Math.round(
|
||||
Math.pow(1 - progress, 2) * fromY
|
||||
+ 2 * (1 - progress) * progress * controlY
|
||||
+ Math.pow(progress, 2) * toY
|
||||
);
|
||||
movePoints.add(new int[]{x, y});
|
||||
}
|
||||
return movePoints;
|
||||
}
|
||||
|
||||
private static double easeInOutCubic(double value) {
|
||||
return value < 0.5d
|
||||
? 4d * value * value * value
|
||||
: 1d - Math.pow(-2d * value + 2d, 3d) / 2d;
|
||||
}
|
||||
|
||||
private static ZlbOrderInfo.ZlbData.TrackList buildTrackPoint(int x, int y, int t, String type) {
|
||||
ZlbOrderInfo.ZlbData.TrackList data = new ZlbOrderInfo.ZlbData.TrackList();
|
||||
data.setX(x);
|
||||
data.setY(y);
|
||||
data.setT(t);
|
||||
data.setType(type);
|
||||
return data;
|
||||
}
|
||||
|
||||
private static int randomBetween(int minInclusive, int maxInclusive) {
|
||||
return ThreadLocalRandom.current().nextInt(minInclusive, maxInclusive + 1);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class DomainDynamicAnalysisTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.DOMAIN_DYNAMIC_ANALYSIS_TASK.getModeleCode();
|
||||
return ScheduleEnums.DOMAIN_DYNAMIC_ANALYSIS_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,4 +20,7 @@ public class GladosConstants {
|
||||
* 签到请求体
|
||||
*/
|
||||
public static final String GLADOS_CHECK_IN_BODY = "{\"token\":\"glados.cloud\"}";
|
||||
|
||||
|
||||
public static final String GLADOS_POINTS_LIST_URL = GLADOS_URL_PREFIX + "/api/user/points";
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class GladosCheckInTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.GLADOS_CHECK_IN_TASK.getModeleCode();
|
||||
return ScheduleEnums.GLADOS_CHECK_IN_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,17 +2,15 @@ package com.xiang.service.module.glados.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.common.factory.ScriptDingTalkFactory;
|
||||
import com.xiang.common.pojo.glados.GladosRunLogDO;
|
||||
import com.xiang.common.pojo.glados.GladosUserDO;
|
||||
import com.xiang.common.pojo.glados.resp.CheckInResp;
|
||||
import com.xiang.common.pojo.glados.resp.GLaDOSResponse;
|
||||
import com.xiang.common.pojo.glados.resp.GladosPointsResp;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
import com.xiang.common.utils.HttpService;
|
||||
import com.xiang.service.module.glados.constants.GladosConstants;
|
||||
import com.xiang.service.module.glados.manage.IGladosRunLogManage;
|
||||
import com.xiang.service.module.glados.manage.IGladosUserManage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -86,14 +84,44 @@ public class GLaDOSServiceImpl implements IGLaDOSService {
|
||||
checkInV2(gladosUserDO, new StringBuilder());
|
||||
}
|
||||
|
||||
public boolean checkInV2(GladosUserDO user, StringBuilder sb) {
|
||||
private GladosPointsResp pointsList(GladosUserDO user) {
|
||||
Map<String, String> header = Maps.newHashMap();
|
||||
header.put("Cookie", user.getCookie());
|
||||
|
||||
String response = null;
|
||||
|
||||
try {
|
||||
response = HttpService.doGet(GladosConstants.GLADOS_POINTS_LIST_URL, header, null);
|
||||
} catch (Exception e) {
|
||||
log.error("http请求异常:{}", user.getEmail());
|
||||
return null;
|
||||
}
|
||||
if (org.apache.commons.lang3.StringUtils.isBlank(response)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
GladosPointsResp gLaDOSResponse = JSONObject.parseObject(response, new TypeReference<GladosPointsResp>() {
|
||||
});
|
||||
if (Objects.isNull(gLaDOSResponse)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (0 == gLaDOSResponse.getCode()) {
|
||||
// 成功请求
|
||||
return gLaDOSResponse;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean checkInV2(GladosUserDO user, StringBuilder sb) {
|
||||
Map<String, String> header = Maps.newHashMap();
|
||||
header.put("Cookie", user.getCookie());
|
||||
|
||||
String response = null;
|
||||
GladosPointsResp gladosPointsResp = null;
|
||||
try {
|
||||
response = HttpService.doPost(GladosConstants.GLADOS_CHECK_IN_URL, header, GladosConstants.GLADOS_CHECK_IN_BODY);
|
||||
gladosPointsResp = pointsList(user);
|
||||
} catch (Exception e) {
|
||||
log.error("http请求异常:{}", user.getEmail());
|
||||
return false;
|
||||
@@ -113,9 +141,13 @@ public class GLaDOSServiceImpl implements IGLaDOSService {
|
||||
if (0 == gLaDOSResponse.getCode()) {
|
||||
// 成功请求
|
||||
if (Objects.nonNull(gLaDOSResponse.getPoints()) && 0 != gLaDOSResponse.getPoints()) {
|
||||
String points = null;
|
||||
if (Objects.nonNull(gladosPointsResp)) {
|
||||
points = gladosPointsResp.getPoints();
|
||||
}
|
||||
// 签到成功
|
||||
dingTalkService.sendMsg("[时间:" + LocalDateTime.now() + "] 用户: " +
|
||||
user.getEmail() + "签到成功,获得积分:" + gLaDOSResponse.getPoints());
|
||||
user.getEmail() + "签到成功,获得积分:" + gLaDOSResponse.getPoints() + ",可用积分数量:" + points);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.xiang.service.module.glados.service;
|
||||
|
||||
import com.xiang.common.pojo.glados.GladosUserDO;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 定时任务配置器
|
||||
*
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 08:56
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class JntyzxMiniappScheduleConfig {
|
||||
|
||||
private final JtTokenRefreshTask jtTokenRefreshTask;
|
||||
private final JtVenuePullTask jtVenuePullTask;
|
||||
private final JtVenueSubscribeTask jtVenueSubscribeTask;
|
||||
private final JtVenueTomorrowPullTask jtVenueTomorrowPullTask;
|
||||
private final JntyzxUserInfoConfigTask jntyzxUserInfoConfigTask;
|
||||
private final JtVenueInfoTodayResultTask jtVenueInfoTodayResultTask;
|
||||
private final JtVenueInfoTomorrowResultTask jtVenueInfoTomorrowResultTask;
|
||||
|
||||
/**
|
||||
* token刷新
|
||||
*/
|
||||
@Scheduled(cron = "0 20,50 * * * ?")
|
||||
@GetMapping("/jtTokenRefreshTask")
|
||||
public void jtTokenRefreshTask() {
|
||||
jtTokenRefreshTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每分钟场地信息更新
|
||||
*/
|
||||
@Scheduled(cron = "0 0/1 10-18 * * ?")
|
||||
@GetMapping("/jtVenuePullTask")
|
||||
public void jtVenuePullTask() {
|
||||
jtVenuePullTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取第二天场地信息
|
||||
*/
|
||||
@Scheduled(cron = "0 30 8 * * ?")
|
||||
@GetMapping("/jtVenueTomorrowPullTask")
|
||||
public void jtVenueTomorrowPullTask() {
|
||||
jtVenueTomorrowPullTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置下单用户场地数据
|
||||
*/
|
||||
@Scheduled(cron = "0 40 8 * * ?")
|
||||
@GetMapping("/jtUserInfoConfig")
|
||||
public void jtUserInfoConfig() {
|
||||
jntyzxUserInfoConfigTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下单定时任务
|
||||
*/
|
||||
@Scheduled(cron = "0 0 9 * * ?")
|
||||
@GetMapping("/jtVenueSubscribeTask")
|
||||
public void jtVenueSubscribeTask() {
|
||||
jtVenueSubscribeTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 当天场地订阅结果
|
||||
*/
|
||||
@Scheduled(cron = "0 0 17 * * ?")
|
||||
@GetMapping("/jtVenueInfoTodayResultTask")
|
||||
public void jtVenueInfoTodayResultTask() {
|
||||
jtVenueInfoTodayResultTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 第二天场地订阅结果
|
||||
*/
|
||||
@Scheduled(cron = "0 10 9 * * ?")
|
||||
@GetMapping("/jtVenueInfoTomorrowResultTask")
|
||||
public void jtVenueInfoTomorrowResultTask() {
|
||||
jtVenueInfoTomorrowResultTask.run();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.xiang.common.enums.RedisKeyConstant;
|
||||
import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||
import com.xiang.common.service.IScheduleRunLogService;
|
||||
import com.xiang.common.utils.DateUtils;
|
||||
import com.xiang.common.utils.RedisService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserInfoService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserTokenInfoService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IVenueService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.VenueInfoUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户场地配置任务 每日8:40运行
|
||||
*
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 09:58
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class JntyzxUserInfoConfigTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final IVenueService venueService;
|
||||
private final IUserInfoService userInfoService;
|
||||
private final JntyzxDingTalkFactory jntyzxDingTalkFactory;
|
||||
private final RedisService redisService;
|
||||
|
||||
public JntyzxUserInfoConfigTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
IUserTokenInfoService userTokenInfoService,
|
||||
IVenueService venueService,
|
||||
IUserInfoService userInfoService,
|
||||
JntyzxDingTalkFactory jntyzxDingTalkFactory,
|
||||
RedisService redisService) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.userTokenInfoService = userTokenInfoService;
|
||||
this.venueService = venueService;
|
||||
this.userInfoService = userInfoService;
|
||||
this.jntyzxDingTalkFactory = jntyzxDingTalkFactory;
|
||||
this.redisService = redisService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTaskName() {
|
||||
return ScheduleEnums.JNTYZX_USER_INFO_CONFIG.getTaskName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.JNTYZX_USER_INFO_CONFIG.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleName() {
|
||||
return ScheduleEnums.JNTYZX_USER_INFO_CONFIG.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||
TaskResult taskResult = new TaskResult();
|
||||
taskResult.setSuccess(false);
|
||||
List<VenueInfoDO> venueInfoDOS = venueService.queryTomorrowCanBuyVenue();
|
||||
if (CollectionUtils.isEmpty(venueInfoDOS)) {
|
||||
taskResult.setSummary("无可用场地");
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
String time = (String) redisService.get(RedisKeyConstant.JNTYZX_SUBSCRIBE_TIME_KEY);
|
||||
if (StringUtils.isBlank(time)) {
|
||||
time = "18:00";
|
||||
}
|
||||
String finalTime = time;
|
||||
venueInfoDOS = VenueInfoUtils.filterVenueList(finalTime, venueInfoDOS);
|
||||
if (CollectionUtils.isEmpty(venueInfoDOS)) {
|
||||
taskResult.setSummary("无可用场地");
|
||||
return taskResult;
|
||||
}
|
||||
venueInfoDOS = venueInfoDOS.stream()
|
||||
.filter(item -> !item.getPlaceName().contains("小馆"))
|
||||
.sorted(Comparator.comparing(item -> VenueInfoUtils.sortVenueInfo(item.getPlaceName())))
|
||||
.toList();
|
||||
|
||||
List<UserTokenInfoDO> users = userTokenInfoService.getCanOrderUser();
|
||||
if (CollectionUtils.isEmpty(users)) {
|
||||
taskResult.setSummary("无可用用户");
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
List<UserInfoDO> list = Lists.newArrayList();
|
||||
int i = 0;
|
||||
userInfoService.delAll();
|
||||
for (UserTokenInfoDO user : users) {
|
||||
VenueInfoDO venueInfoDO = venueInfoDOS.get(i);
|
||||
UserInfoDO userInfoDO = new UserInfoDO();
|
||||
userInfoDO.setName(user.getName());
|
||||
userInfoDO.setWeek(DateUtils.getWeekDay(venueInfoDO.getDate()));
|
||||
userInfoDO.setType("1");
|
||||
userInfoDO.setPlaceName(venueInfoDO.getPlaceName());
|
||||
userInfoDO.setSiteTimeName(venueInfoDO.getSjName().split("-")[0]);
|
||||
userInfoDO.setIsBook(0);
|
||||
list.add(userInfoDO);
|
||||
i++;
|
||||
if (i == venueInfoDOS.size()) {
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
userInfoService.batchSave(list);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (UserInfoDO user : list) {
|
||||
stringBuilder.append(user.getName()).append("配置预约:").append(user.getPlaceName()).append("\n");
|
||||
}
|
||||
jntyzxDingTalkFactory.sendMsg(stringBuilder.toString());
|
||||
taskResult.setSuccess(Boolean.TRUE);
|
||||
taskResult.setSummary(stringBuilder.toString());
|
||||
}
|
||||
return taskResult;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||
|
||||
import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||
import com.xiang.common.service.IScheduleRunLogService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserTokenInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 用户token刷新定时任务 每半个小时运行一次 在每个小时的20和50分
|
||||
*
|
||||
* @Author: xiang
|
||||
* @Date: 2026-01-15 17:29
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RestController
|
||||
public class JtTokenRefreshTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
|
||||
public JtTokenRefreshTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
IUserTokenInfoService userTokenInfoService) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.userTokenInfoService = userTokenInfoService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTaskName() {
|
||||
return ScheduleEnums.JNTYZX_TOKEN_REFRESH_TASK.getTaskName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.JNTYZX_TOKEN_REFRESH_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleName() {
|
||||
return ScheduleEnums.JNTYZX_TOKEN_REFRESH_TASK.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||
TaskResult taskResult = new TaskResult();
|
||||
|
||||
log.info("【Token】江南体育中心token续期定时任务启动!!!time:{}", System.currentTimeMillis());
|
||||
userTokenInfoService.flushToken();
|
||||
|
||||
taskResult.setSuccess(true);
|
||||
taskResult.setSummary("江体小程序token刷新成功");
|
||||
return taskResult;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||
import com.xiang.common.service.IScheduleRunLogService;
|
||||
import com.xiang.common.utils.DateUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IVenueService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.VenueInfoUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 17:00查询当天的场地预定结果
|
||||
*
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 14:17
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class JtVenueInfoTodayResultTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
private final IVenueService venueService;
|
||||
private final JntyzxDingTalkFactory jntyzxDingTalkFactory;
|
||||
|
||||
public JtVenueInfoTodayResultTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
IVenueService venueService,
|
||||
JntyzxDingTalkFactory jntyzxDingTalkFactory) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.venueService = venueService;
|
||||
this.jntyzxDingTalkFactory = jntyzxDingTalkFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTaskName() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_INFO_TODAY_RESULT_TASK.getTaskName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_INFO_TODAY_RESULT_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleName() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_INFO_TODAY_RESULT_TASK.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||
|
||||
TaskResult taskResult = new TaskResult();
|
||||
taskResult.setSuccess(false);
|
||||
List<SitePositionList> sitePositionLists = venueService.queryVenueService();
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
taskResult.setSummary("场地信息为空");
|
||||
return taskResult;
|
||||
}
|
||||
List<SitePositionList> positionListList6_8 = sitePositionLists.stream().filter(VenueInfoUtils::get628VenueInfo).toList();
|
||||
sendMsg(positionListList6_8, "18:00-20:00");
|
||||
List<SitePositionList> positionListList8_10 = sitePositionLists.stream().filter(VenueInfoUtils::get8210VenueInfo).toList();
|
||||
sendMsg(positionListList8_10, "20:00-22:00");
|
||||
taskResult.setSuccess(true);
|
||||
taskResult.setSummary("场地信息查询定时任务成功");
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
private void sendMsg(List<SitePositionList> positionListList, String time) {
|
||||
if (CollectionUtils.isNotEmpty(positionListList)) {
|
||||
Map<String, SitePositionList> map = Maps.newLinkedHashMap();
|
||||
for (SitePositionList sitePositionList : positionListList) {
|
||||
if (map.containsKey(sitePositionList.getPlaceName())) {
|
||||
continue;
|
||||
}
|
||||
map.put(sitePositionList.getPlaceName(), sitePositionList);
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(DateUtils.getDateFromDate(LocalDate.now()) + "==>"+ time +"场地信息如下:\n");
|
||||
map.forEach((placeName, sitePositionList) -> {
|
||||
sb.append(placeName).append("订购人:").append(sitePositionList.getContacts()).append("\n");
|
||||
});
|
||||
jntyzxDingTalkFactory.sendMsg(sb.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||
import com.xiang.common.service.IScheduleRunLogService;
|
||||
import com.xiang.common.utils.DateUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IVenueService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.VenueInfoUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 9:10分查询第二天的场地预定结果
|
||||
*
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 14:17
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class JtVenueInfoTomorrowResultTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
private final IVenueService venueService;
|
||||
private final JntyzxDingTalkFactory jntyzxDingTalkFactory;
|
||||
|
||||
public JtVenueInfoTomorrowResultTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
IVenueService venueService,
|
||||
JntyzxDingTalkFactory jntyzxDingTalkFactory) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.venueService = venueService;
|
||||
this.jntyzxDingTalkFactory = jntyzxDingTalkFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTaskName() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_INFO_TOMORROW_RESULT_TASK.getTaskName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_INFO_TOMORROW_RESULT_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleName() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_INFO_TOMORROW_RESULT_TASK.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||
|
||||
TaskResult taskResult = new TaskResult();
|
||||
taskResult.setSuccess(false);
|
||||
List<SitePositionList> sitePositionLists = venueService.queryTomorrowVenue();
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
taskResult.setSummary("场地信息为空");
|
||||
return taskResult;
|
||||
}
|
||||
List<SitePositionList> positionListList6_8 = sitePositionLists.stream().filter(VenueInfoUtils::get628VenueInfo).toList();
|
||||
sendMsg(positionListList6_8, "18:00-20:00");
|
||||
List<SitePositionList> positionListList8_10 = sitePositionLists.stream().filter(VenueInfoUtils::get8210VenueInfo).toList();
|
||||
sendMsg(positionListList8_10, "20:00-22:00");
|
||||
taskResult.setSuccess(true);
|
||||
taskResult.setSummary("场地信息查询定时任务成功");
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
private void sendMsg(List<SitePositionList> positionListList, String time) {
|
||||
if (CollectionUtils.isNotEmpty(positionListList)) {
|
||||
Map<String, SitePositionList> map = Maps.newLinkedHashMap();
|
||||
for (SitePositionList sitePositionList : positionListList) {
|
||||
if (map.containsKey(sitePositionList.getPlaceName())) {
|
||||
continue;
|
||||
}
|
||||
map.put(sitePositionList.getPlaceName(), sitePositionList);
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(DateUtils.getDateFromDate(LocalDate.now().plusDays(1)) + "==>"+ time +"场地信息如下:\n");
|
||||
map.forEach((placeName, sitePositionList) -> {
|
||||
sb.append(placeName).append("订购人:").append(sitePositionList.getContacts()).append("\n");
|
||||
});
|
||||
jntyzxDingTalkFactory.sendMsg(sb.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.common.enums.RedisKeyConstant;
|
||||
import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||
import com.xiang.common.service.IScheduleRunLogService;
|
||||
import com.xiang.common.utils.DateUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IJntyzxHttpService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserTokenInfoService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IVenueService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.MsgSendUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.VenueInfoUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.WeekendUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 每日9:00-19:00场地更新信息查询
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class JtVenuePullTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
private final IVenueService venueService;
|
||||
private final MsgSendUtils msgSendUtils;
|
||||
|
||||
public JtVenuePullTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
IUserTokenInfoService userTokenInfoService,
|
||||
IJntyzxHttpService jntyzxHttpService,
|
||||
IVenueService venueService,
|
||||
MsgSendUtils msgSendUtils) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.userTokenInfoService = userTokenInfoService;
|
||||
this.jntyzxHttpService = jntyzxHttpService;
|
||||
this.venueService = venueService;
|
||||
this.msgSendUtils = msgSendUtils;
|
||||
}
|
||||
|
||||
private List<SitePositionList> handleMsgSendList(List<SitePositionList> sitePositionLists, Integer type) {
|
||||
if (type == 1) {
|
||||
sitePositionLists = sitePositionLists.stream()
|
||||
.filter(item -> !item.getPlaceName().contains("小馆"))
|
||||
.filter(VenueInfoUtils::get628VenueInfo)
|
||||
.filter(item -> StringUtils.equals(item.getContacts(), "0"))
|
||||
.toList();
|
||||
} else {
|
||||
sitePositionLists = sitePositionLists.stream()
|
||||
.filter(item -> !item.getPlaceName().contains("小馆"))
|
||||
.filter(VenueInfoUtils::get8210VenueInfo)
|
||||
.filter(item -> StringUtils.equals(item.getContacts(), "0"))
|
||||
.toList();
|
||||
}
|
||||
Map<String, SitePositionList> mapByName = Maps.newLinkedHashMap();
|
||||
for (SitePositionList sitePositionList : sitePositionLists) {
|
||||
if (!mapByName.containsKey(sitePositionList.getPlaceName())) {
|
||||
mapByName.put(sitePositionList.getPlaceName(), sitePositionList);
|
||||
}
|
||||
}
|
||||
return mapByName.values().stream().toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTaskName() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_INFO_PULL_TASK.getTaskName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_INFO_PULL_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleName() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_INFO_PULL_TASK.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||
TaskResult taskResult = new TaskResult();
|
||||
taskResult.setSuccess(false);
|
||||
log.info("【Venue】江体小程序场地数据拉取定时任务启动!!!time:{}", System.currentTimeMillis());
|
||||
List<UserTokenInfoDO> availableUser = userTokenInfoService.getAvailableUser();
|
||||
if (CollectionUtils.isEmpty(availableUser)) {
|
||||
log.info("当前无可用用户查询场地信息!");
|
||||
taskResult.setSuccess(true);
|
||||
taskResult.setSummary("当前无可用用户查询场地信息!");
|
||||
return taskResult;
|
||||
}
|
||||
String token;
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
for (UserTokenInfoDO userTokenInfoDO : availableUser) {
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
continue;
|
||||
}
|
||||
token = userTokenInfoDO.getToken();
|
||||
if (StringUtils.isBlank(token)) {
|
||||
continue;
|
||||
}
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable(WeekendUtils.isWeekend(), token);
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
continue;
|
||||
}
|
||||
venueService.saveOrUpdateTodayVenueInfo(sitePositionLists);
|
||||
|
||||
StringBuffer msg = new StringBuffer();
|
||||
|
||||
List<SitePositionList> sitePositionLists6_8 = handleMsgSendList(sitePositionLists, 1);
|
||||
if (CollectionUtils.isNotEmpty(sitePositionLists6_8)) {
|
||||
msg.append("查询到18:00-20:00空闲场地信息=====>\n时间:").append(DateUtils.getDateFromDate(LocalDate.now())).append("\n");
|
||||
sitePositionLists6_8.forEach(item -> msg.append(item.getPlaceName()).append("\n"));
|
||||
}
|
||||
List<SitePositionList> sitePositionLists8_10 = handleMsgSendList(sitePositionLists, 2);
|
||||
if (CollectionUtils.isNotEmpty(sitePositionLists8_10)) {
|
||||
msg.append("查询到20:00-22:00空闲场地信息=====>\n时间:").append(DateUtils.getDateFromDate(LocalDate.now())).append("\n");
|
||||
sitePositionLists8_10.forEach(item -> msg.append(item.getPlaceName()).append("\n"));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
String key = RedisKeyConstant.JNTYZX_VENUE_MSG_SEND_KEY + RedisKeyConstant.getDate();
|
||||
msgSendUtils.sendMsgRestrict1Hours(key, msg.toString());
|
||||
}
|
||||
taskResult.setSuccess(true);
|
||||
taskResult.setSummary("查询场地信息成功!时间:" + now);
|
||||
return taskResult;
|
||||
}
|
||||
return taskResult;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||
|
||||
import com.xiang.common.enums.RedisKeyConstant;
|
||||
import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||
import com.xiang.common.service.IScheduleRunLogService;
|
||||
import com.xiang.common.utils.RedisService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IJtOrderService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserInfoService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserTokenInfoService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IVenueService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.VenueInfoUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 场地订阅定时任务 每日9:00:00
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RestController
|
||||
public class JtVenueSubscribeTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final IJtOrderService jtOrderService;
|
||||
private final IVenueService venueService;
|
||||
private final JntyzxDingTalkFactory jtDingTalkFactory;
|
||||
private final RedisService redisService;
|
||||
private final IUserInfoService userInfoService;
|
||||
|
||||
public JtVenueSubscribeTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
IUserTokenInfoService userTokenInfoService,
|
||||
IJtOrderService jtOrderService,
|
||||
IVenueService venueService,
|
||||
JntyzxDingTalkFactory jtDingTalkFactory,
|
||||
RedisService redisService,
|
||||
IUserInfoService userInfoService) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.userTokenInfoService = userTokenInfoService;
|
||||
this.jtOrderService = jtOrderService;
|
||||
this.venueService = venueService;
|
||||
this.jtDingTalkFactory = jtDingTalkFactory;
|
||||
this.redisService = redisService;
|
||||
this.userInfoService = userInfoService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTaskName() {
|
||||
return ScheduleEnums.JNTYZX_ORDER_SUBSCRIBE_TASK.getTaskName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.JNTYZX_ORDER_SUBSCRIBE_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleName() {
|
||||
return ScheduleEnums.JNTYZX_ORDER_SUBSCRIBE_TASK.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||
TaskResult taskResult = new TaskResult();
|
||||
taskResult.setSuccess(false);
|
||||
|
||||
log.info("【Subscribe】 江体场地预定定时任务启动!!! time:{}", System.currentTimeMillis());
|
||||
List<UserTokenInfoDO> users = userTokenInfoService.getCanOrderUser();
|
||||
if (CollectionUtils.isEmpty(users)) {
|
||||
log.info("暂无可下单用户, time:{}", System.currentTimeMillis());
|
||||
jtDingTalkFactory.sendMsg("暂无可下单用户, time:" + System.currentTimeMillis());
|
||||
taskResult.setSummary("无可下单用户");
|
||||
return taskResult;
|
||||
}
|
||||
Map<String, UserTokenInfoDO> userMap = users.stream().collect(Collectors.toMap(UserTokenInfoDO::getName, Function.identity(), (a, b) -> a));
|
||||
|
||||
List<VenueInfoDO> venueInfoDOS = venueService.queryTomorrowCanBuyVenue();
|
||||
Map<String, List<VenueInfoDO>> venueInfoMap = venueInfoDOS.stream()
|
||||
.collect(Collectors.groupingByConcurrent(VenueInfoDO::getPlaceName));
|
||||
|
||||
List<UserInfoDO> userInfoDOS = userInfoService.selectAll();
|
||||
if (CollectionUtils.isEmpty(userInfoDOS)) {
|
||||
log.info("暂无可下单用户, time:{}", System.currentTimeMillis());
|
||||
jtDingTalkFactory.sendMsg("暂无可下单用户配置信息, time:" + System.currentTimeMillis());
|
||||
taskResult.setSummary("无可下单用户配置信息");
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
|
||||
for (UserInfoDO userInfoDO : userInfoDOS) {
|
||||
if (venueInfoMap.containsKey(userInfoDO.getPlaceName()) && userMap.containsKey(userInfoDO.getName())) {
|
||||
UserTokenInfoDO userTokenInfoDO = userMap.get(userInfoDO.getName());
|
||||
List<VenueInfoDO> venueInfoDOList = venueInfoMap.get(userInfoDO.getPlaceName());
|
||||
if (CollectionUtils.isEmpty(venueInfoDOList)) {
|
||||
logger.info("用户:{}查询不到场地信息:{}", userInfoDO.getName(), userInfoDO.getPlaceName());
|
||||
continue;
|
||||
}
|
||||
venueInfoDOList = VenueInfoUtils.filterVenueList(userInfoDO.getSiteTimeName(), venueInfoDOList);
|
||||
if (CollectionUtils.isEmpty(venueInfoDOList)) {
|
||||
logger.info("用户:{}无场地信息:{},时间:{}", userInfoDO.getName(), userInfoDO.getPlaceName(), userInfoDO.getSiteTimeName());
|
||||
continue;
|
||||
}
|
||||
|
||||
String placeName = userInfoDO.getPlaceName();
|
||||
|
||||
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
|
||||
//计算9点到现在的时间差
|
||||
//获取江体当前时间
|
||||
LocalTime currentTime = LocalTime.now();
|
||||
LocalTime targetTime = LocalTime.parse("09:00:10");
|
||||
Duration duration = Duration.between(currentTime, targetTime);
|
||||
long milliseconds = duration.toMillis();
|
||||
if (milliseconds <= 0) {
|
||||
milliseconds = 0;
|
||||
}
|
||||
List<VenueInfoDO> finalVenueInfoDOList = venueInfoDOList;
|
||||
executorService.schedule(() -> {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
String valid = (String) redisService.get(RedisKeyConstant.getVenueSubscribeKey(placeName));
|
||||
if (StringUtils.isNotBlank(valid)) {
|
||||
break;
|
||||
}
|
||||
boolean order = jtOrderService.createOrder(finalVenueInfoDOList, userTokenInfoDO);
|
||||
if (order) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("睡眠失败~~~");
|
||||
}
|
||||
}
|
||||
}, milliseconds, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
taskResult.setSuccess(true);
|
||||
taskResult.setSummary("下单执行成功!");
|
||||
return taskResult;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JntyzxResponse;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||
import com.xiang.common.service.IScheduleRunLogService;
|
||||
import com.xiang.common.utils.DateUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IJntyzxHttpService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserTokenInfoService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IVenueService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.VenueInfoUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.WeekendUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 场地信息获取定时任务 每日8:30拉取第二天的场地信息
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JtVenueTomorrowPullTask extends BaseScheduleTaskTemplate {
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
private final JntyzxDingTalkFactory jtDingTalkFactory;
|
||||
private final IVenueService venueService;
|
||||
|
||||
public JtVenueTomorrowPullTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
IUserTokenInfoService userTokenInfoService,
|
||||
IJntyzxHttpService jntyzxHttpService,
|
||||
JntyzxDingTalkFactory jtDingTalkFactory,
|
||||
IVenueService venueService) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.userTokenInfoService = userTokenInfoService;
|
||||
this.jntyzxHttpService = jntyzxHttpService;
|
||||
this.jtDingTalkFactory = jtDingTalkFactory;
|
||||
this.venueService = venueService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTaskName() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_TOMORROW_PULL_TASK.getTaskName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_TOMORROW_PULL_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleName() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_TOMORROW_PULL_TASK.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||
TaskResult taskResult = new TaskResult();
|
||||
taskResult.setSuccess(Boolean.FALSE);
|
||||
log.info("【Venue】江体小程序场地拉取定时任务启动!!!time:{}", System.currentTimeMillis());
|
||||
List<UserTokenInfoDO> availableUser = userTokenInfoService.getAvailableUser();
|
||||
if (CollectionUtils.isEmpty(availableUser)) {
|
||||
log.info("当前无可用用户查询场地信息!");
|
||||
taskResult.setSummary("当前无可用用户查询场地信息");
|
||||
return taskResult;
|
||||
}
|
||||
// 用户信息
|
||||
StringBuffer userMsg = new StringBuffer();
|
||||
availableUser.forEach(item -> {
|
||||
JntyzxResponse jntyzxResponse = jntyzxHttpService.checkDefaultNums(item.getToken(), item.getMemberCardNo());
|
||||
if (Objects.nonNull(jntyzxResponse)) {
|
||||
if (jntyzxResponse.getSuccess()) {
|
||||
userMsg.append("订购人:").append(item.getName()).append("正常下单\n");
|
||||
} else {
|
||||
userMsg.append("订购人:").append(item.getName()).append(jntyzxResponse.getMessage()).append("\n");
|
||||
}
|
||||
}
|
||||
});
|
||||
jtDingTalkFactory.sendMsg(userMsg.toString());
|
||||
|
||||
// 场地信息
|
||||
UserTokenInfoDO userTokenInfoDO = availableUser.get(0);
|
||||
String token = userTokenInfoDO.getToken();
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailableTomorrow(WeekendUtils.isWeekend(), token);
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
taskResult.setSummary("当前无可用场地信息");
|
||||
return taskResult;
|
||||
}
|
||||
venueService.saveTomorrowVenueInfo(sitePositionLists);
|
||||
List<SitePositionList> sitePositionLists6_8 = sitePositionLists.stream().filter(VenueInfoUtils::get628VenueInfo).toList();
|
||||
if (CollectionUtils.isEmpty(sitePositionLists6_8)) {
|
||||
taskResult.setSummary("当前无可用场地信息");
|
||||
return taskResult;
|
||||
}
|
||||
buildMsg(sitePositionLists6_8, "18:00-20:00");
|
||||
List<SitePositionList> sitePositionLists8_10 = sitePositionLists.stream().filter(VenueInfoUtils::get8210VenueInfo).toList();
|
||||
if (CollectionUtils.isEmpty(sitePositionLists8_10)) {
|
||||
taskResult.setSummary("当前无可用场地信息");
|
||||
return taskResult;
|
||||
}
|
||||
buildMsg(sitePositionLists8_10, "20:00-22:00");
|
||||
|
||||
taskResult.setSuccess(Boolean.TRUE);
|
||||
taskResult.setSummary("场地信息获取成功!");
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
private void buildMsg(List<SitePositionList> sitePositionLists, String time) {
|
||||
Map<String, SitePositionList> map = Maps.newLinkedHashMap();
|
||||
for (SitePositionList sitePositionList : sitePositionLists) {
|
||||
if (map.containsKey(sitePositionList.getPlaceName())) {
|
||||
continue;
|
||||
}
|
||||
map.put(sitePositionList.getPlaceName(), sitePositionList);
|
||||
}
|
||||
StringBuffer msg = new StringBuffer("查询江体场地信息=====>\n时间:" + DateUtils.getDateFromDate(LocalDate.now().plusDays(1)) + " " + time + "\n");
|
||||
map.forEach((placeName, sitePositionList) -> {
|
||||
msg.append(placeName).append("订购人:").append(sitePositionList.getContacts()).append("\n");
|
||||
});
|
||||
jtDingTalkFactory.sendMsg(msg.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service;
|
||||
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JntyzxResponse;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.OrderCreateResp;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.UserInfoResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 14:47
|
||||
*/
|
||||
public interface IJntyzxHttpService {
|
||||
|
||||
/**
|
||||
* 查询今日可用场地
|
||||
*/
|
||||
List<SitePositionList> queryAvailable(String isWeekend, String token);
|
||||
|
||||
/**
|
||||
* 查询明日可用场地
|
||||
* @param isWeekend
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
List<SitePositionList> queryAvailableTomorrow(String isWeekend, String token);
|
||||
|
||||
/**
|
||||
* 订单创建
|
||||
* @return
|
||||
*/
|
||||
JntyzxResponse<OrderCreateResp> createOrder(List<VenueInfoDO> venueInfos, String token, String openId);
|
||||
|
||||
/**
|
||||
* 心跳监测
|
||||
* @param token token
|
||||
* @param openId openid
|
||||
* @return
|
||||
*/
|
||||
JntyzxResponse healthDeclaration(String token, String openId);
|
||||
|
||||
/**
|
||||
* 根据openid查询
|
||||
* @param token token
|
||||
* @param openId openId
|
||||
* @return
|
||||
*/
|
||||
JntyzxResponse<UserInfoResponse> queryByOpenId(String token, String openId);
|
||||
|
||||
/**
|
||||
* 校验会员卡状态
|
||||
* @param token token
|
||||
* @param cardNo 会员卡号
|
||||
* @return
|
||||
*/
|
||||
JntyzxResponse checkDefaultNums(String token, String cardNo);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service;
|
||||
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.OrderInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 16:17
|
||||
*/
|
||||
public interface IJtOrderService {
|
||||
|
||||
boolean createOrder(List<VenueInfoDO> venueInfoDOS, UserTokenInfoDO userTokenInfoDO);
|
||||
|
||||
List<OrderInfoDO> queryNoPayOrder();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service;
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserInfoDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 10:00
|
||||
*/
|
||||
public interface IUserInfoService {
|
||||
|
||||
boolean delAll();
|
||||
|
||||
boolean batchSave(List<UserInfoDO> list);
|
||||
|
||||
List<UserInfoDO> selectAll();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service;
|
||||
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 09:22
|
||||
*/
|
||||
public interface IUserTokenInfoService {
|
||||
|
||||
List<UserTokenInfoDO> getAvailableUser();
|
||||
List<UserTokenInfoDO> getCanOrderUser();
|
||||
String getToken(String name);
|
||||
boolean flushSingleToken(String name);
|
||||
boolean flushToken();
|
||||
boolean updateTokenByName(String name, String token);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service;
|
||||
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 16:07
|
||||
*/
|
||||
public interface IVenueService {
|
||||
|
||||
List<SitePositionList> queryVenueService();
|
||||
List<SitePositionList> queryTomorrowVenue();
|
||||
List<VenueInfoDO> queryCanBuyVenue();
|
||||
List<VenueInfoDO> queryTomorrowCanBuyVenue();
|
||||
List<VenueInfoDO> queryToday6210VenueInfo();
|
||||
|
||||
/**
|
||||
* 更新场地信息
|
||||
* @param sitePositionLists
|
||||
* @return
|
||||
*/
|
||||
boolean saveOrUpdateTodayVenueInfo(List<SitePositionList> sitePositionLists);
|
||||
|
||||
/**
|
||||
* 更新第二天的场地信息
|
||||
* @param sitePositionLists
|
||||
* @return
|
||||
*/
|
||||
boolean saveTomorrowVenueInfo(List<SitePositionList> sitePositionLists);
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.SubscribeRequest;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.SubscribeVo;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JntyzxResponse;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.OrderCreateResp;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.UserInfoResponse;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.VenueList;
|
||||
import com.xiang.common.utils.HttpService;
|
||||
import com.xiang.common.utils.JsonUtils;
|
||||
import com.xiang.common.utils.RedisService;
|
||||
import com.xiang.common.enums.JntyzxUrlConstant;
|
||||
import com.xiang.common.manage.jntyzx.miniapp.IOrderCreateInfoManage;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IJntyzxHttpService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.JntyzxSaltEncodeUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-05-14 14:07
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
||||
|
||||
private final RedisService redisService;
|
||||
private final IOrderCreateInfoManage orderCreateInfoManage;
|
||||
|
||||
@Override
|
||||
public List<SitePositionList> queryAvailable(String isWeekend, String token) {
|
||||
String url = JntyzxUrlConstant.QUERY_TODAY_SUBSCRIBE_URL;
|
||||
return querySitePositionInfo(isWeekend, token, url);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<SitePositionList> querySitePositionInfo(String isWeekend, String token, String url) {
|
||||
Map<String, String> header = Maps.newHashMap();
|
||||
header.put("X-Access-Token", token);
|
||||
String resp = null;
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
params.put("gid", "03");
|
||||
params.put("isWeekend", isWeekend);
|
||||
try {
|
||||
resp = HttpService.doGet(url, header, params);
|
||||
} catch (Exception e) {
|
||||
log.error("[doGet] 江南体育中心查询当天场地 请求失败, url:{}", url);
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
if (StringUtils.isEmpty(resp)) {
|
||||
log.warn("[查询场地] 江南体育中心查询当天场地 请求结果为空, url:{}, resp:{}", url, resp);
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
JSONObject jsonObject = JSON.parseObject(resp);
|
||||
if (Objects.isNull(jsonObject)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
String resultStr = JSON.toJSONString(jsonObject.get("result"));
|
||||
if (StringUtils.isBlank(resultStr)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
JSONObject result = JSON.parseObject(resultStr);
|
||||
if (Objects.isNull(result)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
String venueStr = JSON.toJSONString(result.get("venue"));
|
||||
if (StringUtils.isBlank(venueStr)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<VenueList> venueLists = JSON.parseArray(venueStr, VenueList.class);
|
||||
if (CollectionUtils.isEmpty(venueLists)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<SitePositionList> res = Lists.newArrayList();
|
||||
for (VenueList venueList : venueLists) {
|
||||
List<SitePositionList> sitePositionList = venueList.getSitePosition();
|
||||
if (CollectionUtils.isEmpty(sitePositionList)) {
|
||||
continue;
|
||||
}
|
||||
res.addAll(sitePositionList);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SitePositionList> queryAvailableTomorrow(String isWeekend, String token) {
|
||||
String url = JntyzxUrlConstant.QUERY_TOMORROW_SUBSCRIBE_URL;
|
||||
return querySitePositionInfo(isWeekend, token, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JntyzxResponse<OrderCreateResp> createOrder(List<VenueInfoDO> venueInfos, String token, String openId) {
|
||||
List<SubscribeVo> vos = Lists.newArrayList();
|
||||
for (VenueInfoDO venueInfo : venueInfos) {
|
||||
SubscribeVo subscribeVo = new SubscribeVo();
|
||||
subscribeVo.setId(0);
|
||||
subscribeVo.setBallCourtId("03");
|
||||
subscribeVo.setSjName(venueInfo.getSjName());
|
||||
subscribeVo.setScheduleId(String.valueOf(venueInfo.getScheduleId()));
|
||||
subscribeVo.setPlaceName(venueInfo.getPlaceName());
|
||||
subscribeVo.setPlaceId(venueInfo.getPlaceId());
|
||||
subscribeVo.setType("0");
|
||||
subscribeVo.setClassName(venueInfo.getClassName());
|
||||
subscribeVo.setClassCode(venueInfo.getClassCode());
|
||||
subscribeVo.setMoney(venueInfo.getMoney().setScale(0));
|
||||
subscribeVo.setContacts("0");
|
||||
subscribeVo.setContactNumber(null);
|
||||
subscribeVo.setMemberNumber(null);
|
||||
subscribeVo.setAppointments(venueInfo.getAppointments());
|
||||
subscribeVo.setOperator(null);
|
||||
subscribeVo.setEndTime(null);
|
||||
subscribeVo.setBeginTime(null);
|
||||
subscribeVo.setSpecOneTimes(3);
|
||||
subscribeVo.setCtypeCode(venueInfo.getCTypeCode());
|
||||
subscribeVo.setIsWhole(0);
|
||||
subscribeVo.setOrderId(null);
|
||||
subscribeVo.setVotesnum(1);
|
||||
vos.add(subscribeVo);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = buildParamJsonObj(openId);
|
||||
SubscribeRequest subscribeRequest = new SubscribeRequest();
|
||||
|
||||
subscribeRequest.setSubscribeVos(vos);
|
||||
subscribeRequest.setBookTime(venueInfos.get(0).getAppointments());
|
||||
subscribeRequest.setPaymentMethod(1);
|
||||
subscribeRequest.setSvCiphertext(JntyzxSaltEncodeUtils.sonAddSalt(JsonUtils.toJsonString(vos)));
|
||||
subscribeRequest.setJsonObject(jsonObject);
|
||||
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
params.put("X-Access-Token", token);
|
||||
String resp = HttpService.doPost(JntyzxUrlConstant.ADD_SUBSCRIBE, params, JsonUtils.toJsonString(subscribeRequest));
|
||||
log.info("[江体小程序] 羽毛球场地下单响应结果:{}", resp);
|
||||
if (StringUtils.isBlank(resp)) {
|
||||
log.info("[resp] 请求结果为空");
|
||||
return null;
|
||||
}
|
||||
JntyzxResponse<OrderCreateResp> response = JSON.parseObject(resp, new TypeReference<JntyzxResponse<OrderCreateResp>>() {
|
||||
});
|
||||
if (Objects.isNull(response)) {
|
||||
log.info("[res ==> response] 请求结果为空");
|
||||
return null;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
@Override
|
||||
public JntyzxResponse healthDeclaration(String token, String openId) {
|
||||
Map<String, String> headers = Maps.newHashMap();
|
||||
headers.put("X-Access-Token", token);
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
params.put("openId", openId);
|
||||
|
||||
String respStr = HttpService.doGet(JntyzxUrlConstant.HEALTH_DECLARATION, headers, params);
|
||||
if (StringUtils.isBlank(respStr)) {
|
||||
return null;
|
||||
}
|
||||
return JSON.parseObject(respStr, JntyzxResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JntyzxResponse<UserInfoResponse> queryByOpenId(String token, String openId) {
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
params.put("openId", openId);
|
||||
Map<String, String> headers = Maps.newHashMap();
|
||||
headers.put("X-Access-Token", token);
|
||||
|
||||
String resp = HttpService.doGet(JntyzxUrlConstant.QUERY_BY_OPEN_ID, headers, params);
|
||||
JntyzxResponse<UserInfoResponse> response = JSON.parseObject(resp, new TypeReference<JntyzxResponse<UserInfoResponse>>() {
|
||||
});
|
||||
if (Objects.isNull(response)) {
|
||||
log.info("请求结果为空!");
|
||||
return null;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JntyzxResponse checkDefaultNums(String token, String cardNo) {
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
params.put("consNumber", cardNo);
|
||||
Map<String, String> headers = Maps.newHashMap();
|
||||
headers.put("X-Access-Token", token);
|
||||
|
||||
String resp = HttpService.doGet(JntyzxUrlConstant.CHECK_NUM, headers, params);
|
||||
if (StringUtils.isBlank(resp)) {
|
||||
return null;
|
||||
}
|
||||
return JSON.parseObject(resp, JntyzxResponse.class);
|
||||
}
|
||||
|
||||
private static JSONObject buildParamJsonObj(String openId) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("id", "1702581215097257986");
|
||||
jsonObject.put("createBy", null);
|
||||
jsonObject.put("createTime", "2023-09-15 15:12:48");
|
||||
jsonObject.put("updateBy", null);
|
||||
jsonObject.put("updateTime", null);
|
||||
jsonObject.put("sysOrgCode", null);
|
||||
jsonObject.put("openId", openId);
|
||||
jsonObject.put("nickName", "1");
|
||||
jsonObject.put("unionId", null);
|
||||
jsonObject.put("avatarUrl", "https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132");
|
||||
jsonObject.put("remarks", null);
|
||||
jsonObject.put("default01", null);
|
||||
jsonObject.put("default02", null);
|
||||
jsonObject.put("default03", null);
|
||||
jsonObject.put("default04", null);
|
||||
jsonObject.put("default05", null);
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.xiang.common.exception.BusinessException;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.OrderInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JntyzxResponse;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.OrderCreateResp;
|
||||
import com.xiang.common.utils.RedisService;
|
||||
import com.xiang.common.enums.RedisKeyConstant;
|
||||
import com.xiang.common.manage.jntyzx.miniapp.IOrderCreateInfoManage;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IJntyzxHttpService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IJtOrderService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 16:17
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class OrderInfoServiceImpl implements IJtOrderService {
|
||||
|
||||
private final IOrderCreateInfoManage orderCreateInfoManage;
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
private final RedisService redisService;
|
||||
private final JntyzxDingTalkFactory dingTalkFactory;
|
||||
@Override
|
||||
public List<OrderInfoDO> queryNoPayOrder() {
|
||||
return orderCreateInfoManage.queryNoPayOrder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createOrder(List<VenueInfoDO> venueInfoDOS, UserTokenInfoDO userTokenInfoDO) {
|
||||
|
||||
String order = (String) redisService.get(RedisKeyConstant.JNTYZX_ORDER_CREATE_KEY + userTokenInfoDO.getName() + LocalDate.now());
|
||||
if (StringUtils.isNotBlank(order)) {
|
||||
log.info("用户:{}已经有成功预订了场地", userTokenInfoDO.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
String user = (String) redisService.get(RedisKeyConstant.getCloseCardKey(userTokenInfoDO.getName()));
|
||||
if (StringUtils.isNotBlank(user)) {
|
||||
log.info("用户:{}有锁卡风险,不在请求接口!");
|
||||
return true;
|
||||
}
|
||||
|
||||
JntyzxResponse<OrderCreateResp> orderResp = jntyzxHttpService.createOrder(venueInfoDOS, userTokenInfoDO.getToken(), userTokenInfoDO.getOpenId());
|
||||
if (Objects.isNull(orderResp)) {
|
||||
return false;
|
||||
}
|
||||
if (orderResp.getSuccess()) {
|
||||
OrderCreateResp result = orderResp.getResult();
|
||||
if (Objects.nonNull(result)) {
|
||||
String orderId = result.getId();
|
||||
if (StringUtils.isNotBlank(orderId)) {
|
||||
redisService.set(RedisKeyConstant.JNTYZX_ORDER_CREATE_KEY + userTokenInfoDO.getName() + LocalDate.now(), orderId);
|
||||
OrderInfoDO orderInfoDO = new OrderInfoDO();
|
||||
orderInfoDO.setOrderId(orderId);
|
||||
orderInfoDO.setCreateTime(LocalDateTime.now());
|
||||
orderInfoDO.setUsername(userTokenInfoDO.getName());
|
||||
orderInfoDO.setPlaceName(venueInfoDOS.get(0).getPlaceName());
|
||||
orderInfoDO.setDate(LocalDate.now());
|
||||
orderInfoDO.setOrderStatus(0);
|
||||
orderCreateInfoManage.save(orderInfoDO);
|
||||
}
|
||||
}
|
||||
dingTalkFactory.sendMsg("用户" + userTokenInfoDO.getName() + "小程序预订场地号:" + venueInfoDOS.get(0).getPlaceName() + "结果返回:" + JSON.toJSONString(orderResp));
|
||||
return true;
|
||||
} else {
|
||||
dingTalkFactory.sendMsg("用户" + userTokenInfoDO.getName() + "小程序预订场地号:" + venueInfoDOS.get(0).getPlaceName() + "结果返回:" + JSON.toJSONString(orderResp));
|
||||
if (orderResp.getMessage().contains("锁卡")) {
|
||||
log.info("有锁卡风险,不在请求,用户:{}", userTokenInfoDO.getName());
|
||||
throw new BusinessException("即将锁卡,不再请求");
|
||||
}
|
||||
if (orderResp.getMessage().contains("限制")) {
|
||||
log.info("改会员卡被限制,不在请求,用户:{}", userTokenInfoDO.getName());
|
||||
redisService.set(RedisKeyConstant.getCloseCardKey(userTokenInfoDO.getName()), "true");
|
||||
throw new BusinessException("会员卡被限制,不在请求");
|
||||
}
|
||||
if (orderResp.getMessage().contains("已有人预订")) {
|
||||
log.info("该场地已被人预定,更换场地, 用户:{}", userTokenInfoDO.getName());
|
||||
redisService.set(RedisKeyConstant.getVenueSubscribeKey(venueInfoDOS.get(0).getPlaceName()), "true");
|
||||
}
|
||||
if (orderResp.getMessage().contains("预约场地不能超过2个")) {
|
||||
log.info("用户:{}已经预约场地", userTokenInfoDO.getName());
|
||||
throw new BusinessException("用户已经预约场地");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service.impl;
|
||||
|
||||
import com.xiang.common.manage.jntyzx.miniapp.IUserInfoManage;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserInfoDO;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserInfoService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 10:18
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class UserInfoServiceImpl implements IUserInfoService {
|
||||
|
||||
private final IUserInfoManage userInfoManage;
|
||||
|
||||
@Override
|
||||
public boolean delAll() {
|
||||
return userInfoManage.delAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean batchSave(List<UserInfoDO> list) {
|
||||
return userInfoManage.saveBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserInfoDO> selectAll() {
|
||||
return userInfoManage.list();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xiang.common.exception.BusinessException;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.manage.jntyzx.miniapp.IUserRestrictionManage;
|
||||
import com.xiang.common.manage.jntyzx.miniapp.IUserTokenInfoManage;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserRestrictionInfo;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JntyzxResponse;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.UserInfoResponse;
|
||||
import com.xiang.common.utils.DateUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IJntyzxHttpService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserTokenInfoService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 09:22
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class UserTokenInfoServiceImpl implements IUserTokenInfoService {
|
||||
|
||||
private final IUserTokenInfoManage userTokenInfoManage;
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
private final JntyzxDingTalkFactory jtDingTalkFactory;
|
||||
private final IUserRestrictionManage userRestrictionManage;
|
||||
|
||||
|
||||
@Override
|
||||
public List<UserTokenInfoDO> getAvailableUser() {
|
||||
return userTokenInfoManage.listUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToken(String name) {
|
||||
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getByName(name);
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
return null;
|
||||
}
|
||||
return userTokenInfoDO.getToken();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserTokenInfoDO> getCanOrderUser() {
|
||||
return userTokenInfoManage.listCanOrder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean flushSingleToken(String name) {
|
||||
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getByName(name);
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
log.info("用户信息不存在,无需进行监测!");
|
||||
return false;
|
||||
}
|
||||
return healthDeclaration(userTokenInfoDO);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean flushToken() {
|
||||
List<UserTokenInfoDO> userTokenInfoDOS = userTokenInfoManage.list();
|
||||
if (CollectionUtils.isEmpty(userTokenInfoDOS)) {
|
||||
log.info("【心跳监测】查询用户信息为空,无需操作");
|
||||
return true;
|
||||
}
|
||||
userTokenInfoDOS.forEach(this::healthDeclaration);
|
||||
// 信息更新
|
||||
userTokenInfoDOS = userTokenInfoManage.list();
|
||||
userTokenInfoDOS.forEach(this::queryMemberCardInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateTokenByName(String name, String token) {
|
||||
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getByName(name);
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
throw new BusinessException("用户信息不存在!");
|
||||
}
|
||||
userTokenInfoDO.setToken(token);
|
||||
boolean flag = userTokenInfoManage.updateById(userTokenInfoDO);
|
||||
jtDingTalkFactory.sendMsg("用户:" + name + ",token更新成功!");
|
||||
return flag;
|
||||
}
|
||||
|
||||
private boolean healthDeclaration(UserTokenInfoDO userTokenInfoDO) {
|
||||
if (StringUtils.isBlank(userTokenInfoDO.getToken()) || StringUtils.isBlank(userTokenInfoDO.getOpenId())) {
|
||||
log.info("用户信息异常:{}", JSONObject.toJSONString(userTokenInfoDO));
|
||||
return false;
|
||||
}
|
||||
JntyzxResponse jntyzxResponse = jntyzxHttpService.healthDeclaration(userTokenInfoDO.getToken(), userTokenInfoDO.getOpenId());
|
||||
if (Objects.isNull(jntyzxResponse)) {
|
||||
log.info("用户名:{}心跳监测失败!", userTokenInfoDO.getName());
|
||||
}
|
||||
boolean flag = StringUtils.contains(jntyzxResponse.getMessage(), "已存在");
|
||||
if (flag) {
|
||||
log.info("用户名:{}心跳成功✅✅✅✅✅✅", userTokenInfoDO.getName());
|
||||
userTokenInfoDO.setStatus(1);
|
||||
userTokenInfoManage.updateById(userTokenInfoDO);
|
||||
} else {
|
||||
jtDingTalkFactory.sendMsg("用户名:" + userTokenInfoDO.getName() + "心跳失败,消息:" + jntyzxResponse.getMessage());
|
||||
userTokenInfoDO.setStatus(0);
|
||||
userTokenInfoManage.updateById(userTokenInfoDO);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户信息
|
||||
*
|
||||
* @param userTokenInfoDO 用户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private void queryMemberCardInfo(UserTokenInfoDO userTokenInfoDO) {
|
||||
if (StringUtils.isBlank(userTokenInfoDO.getToken()) || StringUtils.isBlank(userTokenInfoDO.getOpenId())) {
|
||||
log.info("用户信息异常:{}", JSONObject.toJSONString(userTokenInfoDO));
|
||||
return;
|
||||
}
|
||||
JntyzxResponse<UserInfoResponse> response = jntyzxHttpService.queryByOpenId(userTokenInfoDO.getToken(), userTokenInfoDO.getOpenId());
|
||||
if (Objects.isNull(response)) {
|
||||
return;
|
||||
}
|
||||
if (response.getSuccess()) {
|
||||
UserInfoResponse userInfoResponse = response.getResult();
|
||||
userTokenInfoDO.setMemberCardNo(userInfoResponse.getConsCard());
|
||||
if (StringUtils.isNotBlank(userInfoResponse.getRestrictionDeadline2())) {
|
||||
userTokenInfoDO.setIsRestriction(1);
|
||||
userTokenInfoDO.setIsOrder(0);
|
||||
UserRestrictionInfo userRestrictionInfo = userRestrictionManage.queryByUserId(userTokenInfoDO.getId());
|
||||
if (Objects.isNull(userRestrictionInfo)) {
|
||||
userRestrictionInfo = new UserRestrictionInfo();
|
||||
userRestrictionInfo.setUserId(userTokenInfoDO.getId());
|
||||
userRestrictionInfo.setRestrictionDeadline(DateUtils.getDateTimeFromStr(userInfoResponse.getRestrictionDeadline2()));
|
||||
userRestrictionInfo.setRestrictionDesc(userInfoResponse.getRestrictionDescription());
|
||||
userRestrictionManage.save(userRestrictionInfo);
|
||||
} else {
|
||||
userRestrictionInfo.setRestrictionDeadline(DateUtils.getDateTimeFromStr(userInfoResponse.getRestrictionDeadline2()));
|
||||
userRestrictionInfo.setRestrictionDesc(userInfoResponse.getRestrictionDescription());
|
||||
userRestrictionManage.updateById(userRestrictionInfo);
|
||||
}
|
||||
} else {
|
||||
userTokenInfoDO.setIsRestriction(0);
|
||||
userTokenInfoDO.setIsOrder(1);
|
||||
}
|
||||
userTokenInfoManage.updateById(userTokenInfoDO);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user