feat:江体小程序
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.constants;
|
||||
|
||||
|
||||
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 String getDate() {
|
||||
LocalDate now = LocalDate.now();
|
||||
return ":" + DateUtils.getDateFromDate(now);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.constants;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 13:46
|
||||
*/
|
||||
public class UrlConstant {
|
||||
|
||||
/**
|
||||
* 江南体育中心基础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";
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.converts;
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JtUserVo;
|
||||
import com.xiang.service.module.jntyzx.miniapp.entity.pojo.UserTokenInfoDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Named;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface UserConverter {
|
||||
|
||||
UserConverter INSTANCE = Mappers.getMapper(UserConverter.class);
|
||||
@Mapping(source = "id", target = "userId")
|
||||
@Mapping(source = "isOrder", target = "isOrder", qualifiedByName = "isOrder")
|
||||
@Mapping(source = "isRestriction", target = "isRestriction", qualifiedByName = "isRestrict")
|
||||
JtUserVo convert(UserTokenInfoDO userTokenInfoDO);
|
||||
List<JtUserVo> convert(List<UserTokenInfoDO> userTokenInfoDOs);
|
||||
|
||||
@Named("isOrder")
|
||||
default Boolean isOrder(Integer value) {
|
||||
return Objects.nonNull(value) && Objects.equals(value, 1);
|
||||
}
|
||||
|
||||
@Named("isRestrict")
|
||||
default Boolean isRestrict(Integer value) {
|
||||
return Objects.nonNull(value) && Objects.equals(value, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.converts;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.VenueInfoQueryResp;
|
||||
import com.xiang.service.module.jntyzx.miniapp.entity.pojo.VenueInfoDO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-04-09 09:54
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface VenueInfoConverter {
|
||||
|
||||
Page<VenueInfoQueryResp> toPage(Page<VenueInfoDO> page);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
|
||||
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,13 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
|
||||
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.service.module.jntyzx.miniapp.manage;
|
||||
|
||||
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,22 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.VenueInfoQueryRequest;
|
||||
|
||||
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);
|
||||
|
||||
Page<VenueInfoDO> page(VenueInfoQueryRequest request);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
|
||||
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.service.module.jntyzx.miniapp.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,27 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
|
||||
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.service.module.jntyzx.miniapp.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.service.module.jntyzx.miniapp.manage;
|
||||
|
||||
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.service.module.jntyzx.miniapp.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,50 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.VenueInfoQueryRequest;
|
||||
import com.xiang.service.module.jntyzx.miniapp.mapper.JntyzxVenueInfoMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VenueInfoDO> page(VenueInfoQueryRequest request) {
|
||||
Page<VenueInfoDO> page = new Page<>(request.getCurrent(), request.getPageSize());
|
||||
LambdaQueryWrapper<VenueInfoDO> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(VenueInfoDO::getDate, request.getDate());
|
||||
if (StringUtils.isNotBlank(request.getSj())) {
|
||||
lqw.eq(VenueInfoDO::getSjName, request.getSj());
|
||||
}
|
||||
if (StringUtils.isNotBlank(request.getPlaceName())) {
|
||||
lqw.like(VenueInfoDO::getPlaceName, request.getPlaceName());
|
||||
}
|
||||
return baseMapper.selectPage(page, lqw);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.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,11 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.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.service.module.jntyzx.miniapp.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.service.module.jntyzx.miniapp.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> {
|
||||
}
|
||||
@@ -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,33 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service;
|
||||
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.UserAddReq;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.UserQueryReq;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JtUserVo;
|
||||
|
||||
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);
|
||||
|
||||
List<JtUserVo> list(UserQueryReq req);
|
||||
|
||||
Boolean updateStatusByUserName(String username, Integer status);
|
||||
|
||||
Boolean refreshToken(String username);
|
||||
|
||||
Boolean save(UserAddReq req);
|
||||
|
||||
JtUserVo info(Long userId);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.VenueInfoQueryRequest;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.VenueInfoQueryResp;
|
||||
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);
|
||||
|
||||
/**
|
||||
* 查询场地列表信息
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
Page<VenueInfoQueryResp> list(VenueInfoQueryRequest request);
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
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.RedisService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.constants.UrlConstant;
|
||||
import com.xiang.service.module.jntyzx.miniapp.manage.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 = UrlConstant.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 = HttpHelper.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 = UrlConstant.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 = HttpHelper.doPost(UrlConstant.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 = HttpHelper.doGet(UrlConstant.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 = HttpHelper.doGet(UrlConstant.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 = HttpHelper.doGet(UrlConstant.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,98 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.xiang.common.exception.BusinessException;
|
||||
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.service.module.jntyzx.miniapp.constants.RedisKeyConstant;
|
||||
import com.xiang.service.module.jntyzx.miniapp.manage.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 JntyzxHttpServiceImpl 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");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.common.exception.BusinessException;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
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.req.UserAddReq;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.UserQueryReq;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JntyzxResponse;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JtUserVo;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.UserInfoResponse;
|
||||
import com.xiang.common.utils.DateUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.converts.UserConverter;
|
||||
import com.xiang.service.module.jntyzx.miniapp.manage.IUserRestrictionManage;
|
||||
import com.xiang.service.module.jntyzx.miniapp.manage.IUserTokenInfoManage;
|
||||
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.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
private final UserConverter userConverter;
|
||||
|
||||
|
||||
@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) {
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JtUserVo> list(UserQueryReq req) {
|
||||
List<UserTokenInfoDO> userTokenInfoDOS = userTokenInfoManage.queryByList(req);
|
||||
if (CollectionUtils.isEmpty(userTokenInfoDOS)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<Long> idList = userTokenInfoDOS.stream().map(UserTokenInfoDO::getId).toList();
|
||||
List<UserRestrictionInfo> userRestrictionInfos = userRestrictionManage.queryByIdList(idList);
|
||||
Map<Long, UserRestrictionInfo> userRestrictionInfoMap = Maps.newHashMap();
|
||||
if (CollectionUtils.isNotEmpty(userRestrictionInfos)) {
|
||||
userRestrictionInfoMap.putAll(
|
||||
userRestrictionInfos.stream().collect(Collectors.toMap(
|
||||
UserRestrictionInfo::getUserId, Function.identity(), (a, b) -> a)));
|
||||
}
|
||||
List<JtUserVo> jtUserVoList = userConverter.convert(userTokenInfoDOS);
|
||||
jtUserVoList.forEach(item -> {
|
||||
if (userRestrictionInfoMap.containsKey(item.getUserId())) {
|
||||
UserRestrictionInfo userRestrictionInfo = userRestrictionInfoMap.get(item.getUserId());
|
||||
if (Objects.nonNull(userRestrictionInfo)) {
|
||||
if (userRestrictionInfo.getRestrictionDeadline().isAfter(LocalDateTime.now())) {
|
||||
item.setRestrictionDeadline(userRestrictionInfo.getRestrictionDeadline());
|
||||
item.setRestrictionDesc(userRestrictionInfo.getRestrictionDesc());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return jtUserVoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateStatusByUserName(String username, Integer status) {
|
||||
if (StringUtils.isEmpty(username)) {
|
||||
log.error("用户名为空");
|
||||
return false;
|
||||
}
|
||||
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getByName(username);
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
throw new BusinessException("用户不存在!");
|
||||
}
|
||||
userTokenInfoDO.setStatus(status);
|
||||
return userTokenInfoManage.updateById(userTokenInfoDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean refreshToken(String username) {
|
||||
if (StringUtils.isEmpty(username)) {
|
||||
log.error("用户名为空");
|
||||
return false;
|
||||
}
|
||||
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getByName(username);
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
throw new BusinessException("用户不存在!");
|
||||
}
|
||||
return healthDeclaration(userTokenInfoDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean save(UserAddReq req) {
|
||||
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getByName(req.getName());
|
||||
if (Objects.nonNull(userTokenInfoDO)) {
|
||||
throw new BusinessException("用户名已存在!");
|
||||
}
|
||||
userTokenInfoDO = new UserTokenInfoDO();
|
||||
userTokenInfoDO.setName(req.getName());
|
||||
userTokenInfoDO.setToken(req.getToken());
|
||||
userTokenInfoDO.setOpenId(req.getOpenId());
|
||||
userTokenInfoDO.setStatus(req.getStatus());
|
||||
userTokenInfoDO.setIsOrder(1);
|
||||
userTokenInfoDO.setMemberCardNo(req.getMemberCardNo());
|
||||
userTokenInfoDO.setIsRestriction(0);
|
||||
userTokenInfoDO.setUpdateTime(LocalDateTime.now());
|
||||
return userTokenInfoManage.save(userTokenInfoDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JtUserVo info(Long userId) {
|
||||
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getById(userId);
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
throw new BusinessException("用户不存在!");
|
||||
}
|
||||
JtUserVo jtUserVo = userConverter.convert(userTokenInfoDO);
|
||||
UserRestrictionInfo userRestrictionInfo = userRestrictionManage.queryByUserId(userId);
|
||||
if (Objects.nonNull(userRestrictionInfo)) {
|
||||
if (userRestrictionInfo.getRestrictionDeadline().isAfter(LocalDateTime.now())) {
|
||||
jtUserVo.setRestrictionDeadline(userRestrictionInfo.getRestrictionDeadline());
|
||||
jtUserVo.setRestrictionDesc(userRestrictionInfo.getRestrictionDesc());
|
||||
}
|
||||
}
|
||||
return jtUserVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户信息
|
||||
*
|
||||
* @param userTokenInfoDO 用户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private void queryMemberCardInfo(UserTokenInfoDO userTokenInfoDO) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
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.VenueInfoQueryRequest;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.VenueInfoQueryResp;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||
import com.xiang.common.utils.DateUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.converts.VenueInfoConverter;
|
||||
import com.xiang.service.module.jntyzx.miniapp.manage.IVenueInfoManage;
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
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.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 16:08
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class VenueServiceImpl implements IVenueService {
|
||||
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
private final IVenueInfoManage venueInfoManage;
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final VenueInfoConverter venueInfoConverter;
|
||||
|
||||
@Override
|
||||
public List<SitePositionList> queryVenueService() {
|
||||
String token = userTokenInfoService.getToken("Xiang");
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable("1", token);
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
updateDatabase(sitePositionLists, true);
|
||||
return sitePositionLists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SitePositionList> queryTomorrowVenue() {
|
||||
String token = userTokenInfoService.getToken("Xiang");
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailableTomorrow("1", token);
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
updateDatabase(sitePositionLists, false);
|
||||
return sitePositionLists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VenueInfoDO> queryCanBuyVenue() {
|
||||
return venueInfoManage.queryByType(LocalDate.now(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VenueInfoDO> queryTomorrowCanBuyVenue() {
|
||||
return venueInfoManage.queryByType(LocalDate.now().plusDays(1), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VenueInfoDO> queryToday6210VenueInfo() {
|
||||
List<VenueInfoDO> venueInfoDOS = venueInfoManage.queryByDate(LocalDate.now());
|
||||
return venueInfoDOS.stream().filter(item -> VenueInfoUtils.get628VenueInfo(item) || VenueInfoUtils.get8210VenueInfo(item)).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveOrUpdateTodayVenueInfo(List<SitePositionList> sitePositionLists) {
|
||||
List<VenueInfoDO> venueInfoDOS = venueInfoManage.queryByDate(LocalDate.now());
|
||||
Map<String, Map<String, VenueInfoDO>> map = Maps.newHashMap();
|
||||
if (CollectionUtils.isNotEmpty(sitePositionLists)) {
|
||||
Map<String, List<VenueInfoDO>> map1 = venueInfoDOS.stream().collect(Collectors.groupingBy(VenueInfoDO::getPlaceName));
|
||||
map1.forEach((placeName, venueInfos) -> {
|
||||
Map<String, VenueInfoDO> venueInfoDOMap = venueInfoDOS.stream().collect(Collectors.toMap(VenueInfoDO::getSjName, Function.identity(), (a, b) -> a));
|
||||
map.put(placeName, venueInfoDOMap);
|
||||
});
|
||||
}
|
||||
|
||||
for (SitePositionList sitePositionList : sitePositionLists) {
|
||||
if (map.containsKey(sitePositionList.getPlaceName())) {
|
||||
Map<String, VenueInfoDO> venueInfoDOMap = map.get(sitePositionList.getPlaceName());
|
||||
if (venueInfoDOMap.containsKey(sitePositionList.getSjName())) {
|
||||
VenueInfoDO venueInfoDO = venueInfoDOMap.get(sitePositionList.getSjName());
|
||||
venueInfoDO.setPlaceName(sitePositionList.getPlaceName());
|
||||
venueInfoDO.setPlaceMainId(sitePositionList.getId());
|
||||
venueInfoDO.setPlaceId(sitePositionList.getPlaceId());
|
||||
venueInfoDO.setScheduleId(Integer.valueOf(sitePositionList.getScheduleId()));
|
||||
venueInfoDO.setSjName(sitePositionList.getSjName());
|
||||
venueInfoDO.setContacts(sitePositionList.getContacts());
|
||||
venueInfoDO.setType(sitePositionList.getType());
|
||||
venueInfoDO.setMoney(sitePositionList.getMoney());
|
||||
venueInfoDO.setClassName(sitePositionList.getClassName());
|
||||
venueInfoDO.setClassCode(sitePositionList.getClassCode());
|
||||
venueInfoDO.setAppointments(sitePositionList.getAppointments());
|
||||
venueInfoDO.setCTypeCode(sitePositionList.getCtypeCode());
|
||||
venueInfoManage.updateById(venueInfoDO);
|
||||
} else {
|
||||
VenueInfoDO venueInfoDO = new VenueInfoDO();
|
||||
venueInfoDO.setDate(LocalDate.now());
|
||||
venueInfoDO.setCreateTime(LocalDateTime.now());
|
||||
venueInfoDO.setPlaceName(sitePositionList.getPlaceName());
|
||||
venueInfoDO.setPlaceMainId(sitePositionList.getId());
|
||||
venueInfoDO.setPlaceId(sitePositionList.getPlaceId());
|
||||
venueInfoDO.setScheduleId(Integer.valueOf(sitePositionList.getScheduleId()));
|
||||
venueInfoDO.setSjName(sitePositionList.getSjName());
|
||||
venueInfoDO.setContacts(sitePositionList.getContacts());
|
||||
venueInfoDO.setType(sitePositionList.getType());
|
||||
venueInfoDO.setMoney(sitePositionList.getMoney());
|
||||
venueInfoDO.setClassName(sitePositionList.getClassName());
|
||||
venueInfoDO.setClassCode(sitePositionList.getClassCode());
|
||||
venueInfoDO.setAppointments(sitePositionList.getAppointments());
|
||||
venueInfoDO.setCTypeCode(sitePositionList.getCtypeCode());
|
||||
venueInfoManage.save(venueInfoDO);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveTomorrowVenueInfo(List<SitePositionList> sitePositionLists) {
|
||||
for (SitePositionList sitePositionList : sitePositionLists) {
|
||||
VenueInfoDO venueInfoDO = new VenueInfoDO();
|
||||
venueInfoDO.setDate(LocalDate.now().plusDays(1));
|
||||
venueInfoDO.setCreateTime(LocalDateTime.now());
|
||||
venueInfoDO.setPlaceName(sitePositionList.getPlaceName());
|
||||
venueInfoDO.setPlaceMainId(sitePositionList.getId());
|
||||
venueInfoDO.setPlaceId(sitePositionList.getPlaceId());
|
||||
venueInfoDO.setScheduleId(Integer.valueOf(sitePositionList.getScheduleId()));
|
||||
venueInfoDO.setSjName(sitePositionList.getSjName());
|
||||
venueInfoDO.setContacts(sitePositionList.getContacts());
|
||||
venueInfoDO.setType(sitePositionList.getType());
|
||||
venueInfoDO.setMoney(sitePositionList.getMoney());
|
||||
venueInfoDO.setClassName(sitePositionList.getClassName());
|
||||
venueInfoDO.setClassCode(sitePositionList.getClassCode());
|
||||
venueInfoDO.setAppointments(sitePositionList.getAppointments());
|
||||
venueInfoDO.setCTypeCode(sitePositionList.getCtypeCode());
|
||||
venueInfoManage.save(venueInfoDO);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VenueInfoQueryResp> list(VenueInfoQueryRequest request) {
|
||||
Page<VenueInfoDO> page = venueInfoManage.page(request);
|
||||
return venueInfoConverter.toPage(page);
|
||||
}
|
||||
|
||||
private void updateDatabase(List<SitePositionList> list, boolean isToday) {
|
||||
List<VenueInfoDO> venueInfoDOS = Lists.newArrayList();
|
||||
if (isToday) {
|
||||
venueInfoDOS.addAll(venueInfoManage.queryByDate(LocalDate.now()));
|
||||
} else {
|
||||
venueInfoDOS.addAll(venueInfoManage.queryByDate(LocalDate.now().plusDays(1)));
|
||||
}
|
||||
|
||||
Map<Integer, List<VenueInfoDO>> map = Maps.newHashMap();
|
||||
if (CollectionUtils.isNotEmpty(venueInfoDOS)) {
|
||||
map.putAll(venueInfoDOS.stream().filter(Objects::nonNull)
|
||||
.collect(Collectors.groupingBy(VenueInfoDO::getPlaceId)));
|
||||
}
|
||||
List<VenueInfoDO> insertList = Lists.newArrayList();
|
||||
for (SitePositionList sitePositionList : list) {
|
||||
if (map.containsKey(sitePositionList.getPlaceId())) {
|
||||
List<VenueInfoDO> venueInfoDOList = map.get(sitePositionList.getPlaceId());
|
||||
Map<String, VenueInfoDO> sjMap = venueInfoDOList.stream().collect(Collectors.toMap(VenueInfoDO::getSjName, Function.identity(), (a, b) -> a));
|
||||
if (sjMap.containsKey(sitePositionList.getSjName())) {
|
||||
VenueInfoDO venueInfoDO = sjMap.get(sitePositionList.getSjName());
|
||||
if (!StringUtils.equals(venueInfoDO.getContacts(), sitePositionList.getContacts())
|
||||
|| !Objects.equals(venueInfoDO.getType(), sitePositionList.getType())
|
||||
|| !Objects.equals(venueInfoDO.getPlaceMainId(), sitePositionList.getId())) {
|
||||
venueInfoDO.setContacts(sitePositionList.getContacts());
|
||||
venueInfoDO.setType(sitePositionList.getType());
|
||||
venueInfoDO.setPlaceMainId(sitePositionList.getId());
|
||||
venueInfoManage.updateById(venueInfoDO);
|
||||
}
|
||||
} else {
|
||||
addIntoInsert(sitePositionList, insertList);
|
||||
}
|
||||
} else {
|
||||
addIntoInsert(sitePositionList, insertList);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(insertList)) {
|
||||
venueInfoManage.saveBatch(insertList);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addIntoInsert(SitePositionList sitePositionList, List<VenueInfoDO> insertList) {
|
||||
VenueInfoDO venueInfoDO = new VenueInfoDO();
|
||||
venueInfoDO.setPlaceName(sitePositionList.getPlaceName());
|
||||
venueInfoDO.setDate(DateUtils.getDateFromStr(sitePositionList.getAppointments()));
|
||||
venueInfoDO.setPlaceMainId(sitePositionList.getId());
|
||||
venueInfoDO.setPlaceId(sitePositionList.getPlaceId());
|
||||
venueInfoDO.setScheduleId(Integer.valueOf(sitePositionList.getScheduleId()));
|
||||
venueInfoDO.setSjName(sitePositionList.getSjName());
|
||||
venueInfoDO.setCreateTime(LocalDateTime.now());
|
||||
venueInfoDO.setContacts(sitePositionList.getContacts());
|
||||
venueInfoDO.setType(sitePositionList.getType());
|
||||
venueInfoDO.setMoney(sitePositionList.getMoney());
|
||||
venueInfoDO.setClassName(sitePositionList.getClassName());
|
||||
venueInfoDO.setClassCode(sitePositionList.getClassCode());
|
||||
venueInfoDO.setAppointments(sitePositionList.getAppointments());
|
||||
venueInfoDO.setCTypeCode(sitePositionList.getCtypeCode());
|
||||
insertList.add(venueInfoDO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.utils;
|
||||
|
||||
|
||||
import com.xiang.common.utils.Base64;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class JntyzxSaltEncodeUtils {
|
||||
|
||||
private static int[] getMonthAndDay() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
int month = currentDate.getMonthValue();
|
||||
int day = currentDate.getDayOfMonth();
|
||||
return new int[]{month, day};
|
||||
}
|
||||
|
||||
public static String sonAddSalt(String json) {
|
||||
String svCiphertext = "";
|
||||
String suiji = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
String token1 = String.valueOf(suiji.charAt((int) (Math.random() * (double) suiji.length())));
|
||||
String token2 = String.valueOf(suiji.charAt((int) (Math.random() * (double) suiji.length())));
|
||||
svCiphertext = Base64.encode(json.getBytes(StandardCharsets.UTF_8));
|
||||
int[] monthAndDay = getMonthAndDay();
|
||||
int month = monthAndDay[0];
|
||||
int day = monthAndDay[1];
|
||||
if (month == 1) {
|
||||
svCiphertext = (svCiphertext = token1 + svCiphertext).substring(0, day - 1) + token2 + svCiphertext.substring(day - 1);
|
||||
} else if (day == 1) {
|
||||
svCiphertext = token2 + svCiphertext.substring(0, month - 1) + token1 + svCiphertext.substring(month - 1);
|
||||
} else {
|
||||
svCiphertext = (svCiphertext = svCiphertext.substring(0, month - 1) + token1 + svCiphertext.substring(month - 1)).substring(0, day - 1) + token2 + svCiphertext.substring(day - 1);
|
||||
}
|
||||
return svCiphertext;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.utils;
|
||||
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.utils.RedisService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.constants.RedisKeyConstant;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-01-26 09:14
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class MsgSendUtils {
|
||||
|
||||
private final RedisService redisService;
|
||||
private final JntyzxDingTalkFactory jtDingTalkFactory;
|
||||
|
||||
/**
|
||||
* 限制钉钉消息发送 1小时最多5次
|
||||
* @param redisKey redis缓存的key
|
||||
* @param msgContent 消息内容
|
||||
*/
|
||||
public void sendMsgRestrict1Hours(String redisKey, String msgContent) {
|
||||
String key = RedisKeyConstant.JNTYZX_VENUE_MSG_SEND_KEY + RedisKeyConstant.getDate();
|
||||
String cache = (String) redisService.get(redisKey);
|
||||
if (StringUtils.isNotBlank(cache)) {
|
||||
int sendNum = Integer.parseInt(cache);
|
||||
if (sendNum >= 0 && sendNum <= 5) {
|
||||
jtDingTalkFactory.sendMsg(msgContent);
|
||||
redisService.set(key, String.valueOf(++sendNum), 1, TimeUnit.HOURS);
|
||||
}
|
||||
} else {
|
||||
jtDingTalkFactory.sendMsg(msgContent);
|
||||
redisService.set(key, "0", 1, TimeUnit.HOURS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.utils;
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 09:55
|
||||
*/
|
||||
public class VenueInfoUtils {
|
||||
|
||||
public static boolean get123VenueInfo4Mor(VenueInfoDO venueInfoDO) {
|
||||
return StringUtils.equals(venueInfoDO.getSjName(), "13:00-14:00") || StringUtils.equals(venueInfoDO.getSjName(), "14:00-15:00");
|
||||
}
|
||||
public static boolean get1221VenueInfo4Mor(VenueInfoDO venueInfoDO) {
|
||||
return StringUtils.equals(venueInfoDO.getSjName(), "12:00-13:00") || StringUtils.equals(venueInfoDO.getSjName(), "13:00-14:00");
|
||||
}
|
||||
public static boolean get628VenueInfo(VenueInfoDO venueInfoDO) {
|
||||
return StringUtils.equals(venueInfoDO.getSjName(), "18:00-19:00") || StringUtils.equals(venueInfoDO.getSjName(), "19:00-20:00");
|
||||
}
|
||||
public static boolean get8210VenueInfo(VenueInfoDO venueInfoDO) {
|
||||
return StringUtils.equals(venueInfoDO.getSjName(), "20:00-21:00") || StringUtils.equals(venueInfoDO.getSjName(), "21:00-22:00");
|
||||
}
|
||||
public static boolean get8210VenueInfo(SitePositionList sitePositionList) {
|
||||
return StringUtils.equals(sitePositionList.getSjName(), "20:00-21:00") || StringUtils.equals(sitePositionList.getSjName(), "21:00-22:00");
|
||||
}
|
||||
|
||||
public static int sortVenueInfo(String placeName) {
|
||||
if (placeName.contains("十号")) {
|
||||
return 0;
|
||||
}
|
||||
if (placeName.contains("二号")) {
|
||||
return 1;
|
||||
}
|
||||
if (placeName.contains("九号")) {
|
||||
return 2;
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.utils;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class WeekendUtils {
|
||||
|
||||
public static String isWeekend() {
|
||||
LocalDate tomorrow = LocalDate.now().plusDays(1);
|
||||
DayOfWeek dayOfWeek = tomorrow.getDayOfWeek();
|
||||
String isWeekend = "0";
|
||||
if (dayOfWeek.getValue() == 6 || dayOfWeek.getValue() == 7 ) {
|
||||
isWeekend = "1";
|
||||
}
|
||||
return isWeekend;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user