package com.junjie.index12306.biz.ticketservice.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
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.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.google.common.collect.Lists;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.junjie.index12306.biz.ticketservice.common.enums.RefundTypeEnum;
import com.junjie.index12306.biz.ticketservice.common.enums.SourceEnum;
import com.junjie.index12306.biz.ticketservice.common.enums.TicketChainMarkEnum;
import com.junjie.index12306.biz.ticketservice.common.enums.TicketStatusEnum;
import com.junjie.index12306.biz.ticketservice.common.enums.VehicleTypeEnum;
import com.junjie.index12306.biz.ticketservice.dao.entity.StationDO;
import com.junjie.index12306.biz.ticketservice.dao.entity.TicketDO;
import com.junjie.index12306.biz.ticketservice.dao.entity.TrainDO;
import com.junjie.index12306.biz.ticketservice.dao.entity.TrainStationPriceDO;
import com.junjie.index12306.biz.ticketservice.dao.entity.TrainStationRelationDO;
import com.junjie.index12306.biz.ticketservice.dao.mapper.StationMapper;
import com.junjie.index12306.biz.ticketservice.dao.mapper.TicketMapper;
import com.junjie.index12306.biz.ticketservice.dao.mapper.TrainMapper;
import com.junjie.index12306.biz.ticketservice.dao.mapper.TrainStationPriceMapper;
import com.junjie.index12306.biz.ticketservice.dao.mapper.TrainStationRelationMapper;
import com.junjie.index12306.biz.ticketservice.dto.domain.PurchaseTicketPassengerDetailDTO;
import com.junjie.index12306.biz.ticketservice.dto.domain.RouteDTO;
import com.junjie.index12306.biz.ticketservice.dto.domain.SeatClassDTO;
import com.junjie.index12306.biz.ticketservice.dto.domain.TicketListDTO;
import com.junjie.index12306.biz.ticketservice.dto.req.CancelTicketOrderReqDTO;
import com.junjie.index12306.biz.ticketservice.dto.req.PurchaseTicketReqDTO;
import com.junjie.index12306.biz.ticketservice.dto.req.RefundTicketReqDTO;
import com.junjie.index12306.biz.ticketservice.dto.req.TicketOrderItemQueryReqDTO;
import com.junjie.index12306.biz.ticketservice.dto.req.TicketPageQueryReqDTO;
import com.junjie.index12306.biz.ticketservice.dto.resp.RefundTicketRespDTO;
import com.junjie.index12306.biz.ticketservice.dto.resp.TicketOrderDetailRespDTO;
import com.junjie.index12306.biz.ticketservice.dto.resp.TicketPageQueryRespDTO;
import com.junjie.index12306.biz.ticketservice.dto.resp.TicketPurchaseRespDTO;
import com.junjie.index12306.biz.ticketservice.remote.PayRemoteService;
import com.junjie.index12306.biz.ticketservice.remote.TicketOrderRemoteService;
import com.junjie.index12306.biz.ticketservice.remote.dto.PayInfoRespDTO;
import com.junjie.index12306.biz.ticketservice.remote.dto.RefundReqDTO;
import com.junjie.index12306.biz.ticketservice.remote.dto.RefundRespDTO;
import com.junjie.index12306.biz.ticketservice.remote.dto.TicketOrderCreateRemoteReqDTO;
import com.junjie.index12306.biz.ticketservice.remote.dto.TicketOrderItemCreateRemoteReqDTO;
import com.junjie.index12306.biz.ticketservice.remote.dto.TicketOrderPassengerDetailRespDTO;
import com.junjie.index12306.biz.ticketservice.service.SeatService;
import com.junjie.index12306.biz.ticketservice.service.TicketService;
import com.junjie.index12306.biz.ticketservice.service.TrainStationService;
import com.junjie.index12306.biz.ticketservice.service.cache.SeatMarginCacheLoader;
import com.junjie.index12306.biz.ticketservice.service.handler.ticket.dto.TrainPurchaseTicketRespDTO;
import com.junjie.index12306.biz.ticketservice.service.handler.ticket.select.TrainSeatTypeSelector;
import com.junjie.index12306.biz.ticketservice.service.handler.ticket.tokenbucket.TicketAvailabilityTokenBucket;
import com.junjie.index12306.biz.ticketservice.toolkit.DateUtil;
import com.junjie.index12306.biz.ticketservice.toolkit.TimeStringComparator;
import com.junjie.index12306.framework.starter.bases.ApplicationContextHolder;
import com.junjie.index12306.framework.starter.cache.DistributedCache;
import com.junjie.index12306.framework.starter.cache.toolkit.CacheUtil;
import com.junjie.index12306.framework.starter.common.toolkit.BeanUtil;
import com.junjie.index12306.framework.starter.convention.exception.ServiceException;
import com.junjie.index12306.framework.starter.convention.result.Result;
import com.junjie.index12306.framework.starter.designpattern.chain.AbstractChainContext;
import com.junjie.index12306.frameworks.starter.user.core.UserContext;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import static com.junjie.index12306.biz.ticketservice.common.constant.Index12306Constant.ADVANCE_TICKET_DAY;
import static com.junjie.index12306.biz.ticketservice.common.constant.RedisKeyConstant.LOCK_PURCHASE_TICKETS;
import static com.junjie.index12306.biz.ticketservice.common.constant.RedisKeyConstant.LOCK_PURCHASE_TICKETS_V2;
import static com.junjie.index12306.biz.ticketservice.common.constant.RedisKeyConstant.LOCK_REGION_TRAIN_STATION;
import static com.junjie.index12306.biz.ticketservice.common.constant.RedisKeyConstant.LOCK_REGION_TRAIN_STATION_MAPPING;
import static com.junjie.index12306.biz.ticketservice.common.constant.RedisKeyConstant.REGION_TRAIN_STATION;
import static com.junjie.index12306.biz.ticketservice.common.constant.RedisKeyConstant.REGION_TRAIN_STATION_MAPPING;
import static com.junjie.index12306.biz.ticketservice.common.constant.RedisKeyConstant.TRAIN_INFO;
import static com.junjie.index12306.biz.ticketservice.common.constant.RedisKeyConstant.TRAIN_STATION_PRICE;
import static com.junjie.index12306.biz.ticketservice.common.constant.RedisKeyConstant.TRAIN_STATION_REMAINING_TICKET;
import static com.junjie.index12306.biz.ticketservice.toolkit.DateUtil.convertDateToLocalTime;
/**
* 车票接口实现
*
*
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class TicketServiceImpl extends ServiceImpl<TicketMapper, TicketDO> implements TicketService, CommandLineRunner {
private final TrainMapper trainMapper;
private final TrainStationRelationMapper trainStationRelationMapper;
private final TrainStationPriceMapper trainStationPriceMapper;
private final DistributedCache distributedCache;
private final TicketOrderRemoteService ticketOrderRemoteService;
private final PayRemoteService payRemoteService;
private final StationMapper stationMapper;
private final SeatService seatService;
private final TrainStationService trainStationService;
private final TrainSeatTypeSelector trainSeatTypeSelector;
private final SeatMarginCacheLoader seatMarginCacheLoader;
private final AbstractChainContext<TicketPageQueryReqDTO> ticketPageQueryAbstractChainContext;
private final AbstractChainContext<PurchaseTicketReqDTO> purchaseTicketAbstractChainContext;
private final AbstractChainCont
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本设计源码提供了一个基于Java的铁路售票系统。项目包含540个文件,主要使用Java编程语言,并包含了Vue、JavaScript、Lua和HTML。文件类型包括427个Java源代码文件、29个XML配置文件、21个Vue组件文件、15个YAML配置文件、12个Imports文件、9个JavaScript脚本文件、8个SQL文件、4个Lua文件、2个GIT忽略文件和2个Markdown文档。该项目是仿照中国某铁路售票系统设计的,使用了本地锁+分布式锁、MQ、令牌桶限流、令牌大闸、分库分表等技术,以实现高并发高可用的售票系统。系统分为两个版本v1.0与v2.0,主master分支就是v2.0。适合用于学习和实践Java、Vue、JavaScript、Lua和HTML技术,以及开发基于Java的铁路售票系统相关的系统。
资源推荐
资源详情
资源评论
收起资源包目录
基于Java的铁路售票系统设计源码 (539个子文件)
.browserslistrc 40B
.gitignore 404B
.gitignore 231B
index.html 611B
favicon.ico 9KB
org.springframework.boot.autoconfigure.AutoConfiguration.imports 121B
org.springframework.boot.autoconfigure.AutoConfiguration.imports 121B
org.springframework.boot.autoconfigure.AutoConfiguration.imports 121B
org.springframework.boot.autoconfigure.AutoConfiguration.imports 94B
org.springframework.boot.autoconfigure.AutoConfiguration.imports 94B
org.springframework.boot.autoconfigure.AutoConfiguration.imports 88B
org.springframework.boot.autoconfigure.AutoConfiguration.imports 88B
org.springframework.boot.autoconfigure.AutoConfiguration.imports 87B
org.springframework.boot.autoconfigure.AutoConfiguration.imports 78B
org.springframework.boot.autoconfigure.AutoConfiguration.imports 77B
org.springframework.boot.autoconfigure.AutoConfiguration.imports 74B
org.springframework.boot.autoconfigure.AutoConfiguration.imports 72B
TicketServiceImpl.java 47KB
TrainSecondClassPurchaseTicketHandler.java 29KB
TrainBusinessClassPurchaseTicketHandler.java 28KB
TrainFirstClassPurchaseTicketHandler.java 27KB
OrderServiceImpl.java 19KB
UserLoginServiceImpl.java 14KB
TicketAvailabilityTokenBucket.java 13KB
Snowflake.java 11KB
TrainSeatTypeSelector.java 10KB
StringRedisTemplateProxy.java 10KB
PassengerServiceImpl.java 9KB
SeatMarginCacheLoader.java 9KB
RefundServiceImpl.java 8KB
PayServiceImpl.java 7KB
DelayCloseOrderConsumer.java 7KB
OrderCommonTableComplexAlgorithm.java 7KB
RegionStationImpl.java 7KB
OrderCommonDataBaseComplexAlgorithm.java 7KB
SeatServiceImpl.java 6KB
ReceiveTextMsgHandler.java 6KB
DistributedCache.java 6KB
ChatApiTemplate.java 6KB
TrainTicketQueryParamVerifyChainFilter.java 5KB
RegionTrainStationJobHandler.java 5KB
OrderItemServiceImpl.java 5KB
AliPayNativeHandler.java 5KB
AliRefundNativeHandler.java 5KB
TrainPurchaseTicketParamVerifyChainHandler.java 5KB
BeanUtil.java 5KB
TicketAvailabilityCacheUpdateHandler.java 5KB
RedisKeyConstant.java 5KB
TicketController.java 5KB
IdempotentSpELByMQExecuteHandler.java 4KB
TrainStationRemainingTicketJobHandler.java 4KB
UserServiceImpl.java 4KB
RefundResultCallbackOrderConsumer.java 4KB
CarriageServiceImpl.java 4KB
PayDataBaseComplexAlgorithm.java 4KB
PayResultCallbackTicketConsumer.java 4KB
TicketOrderController.java 4KB
AbstractTrainPurchaseTicketTemplate.java 4KB
PassengerController.java 4KB
QWENChatApi.java 4KB
TrainStationDetailJobHandler.java 4KB
AbstractStrategyChoose.java 4KB
SeatSelection.java 4KB
CallBackController.java 4KB
OrderCloseCacheAndTokenUpdateHandler.java 4KB
ThreadPoolBuilder.java 4KB
ILogPrintAspect.java 4KB
TokenValidateGatewayFilterFactory.java 3KB
PayTableComplexAlgorithm.java 3KB
StationCalculateUtil.java 3KB
IdempotentTokenExecuteHandler.java 3KB
TrainPurchaseTicketParamStockChainHandler.java 3KB
IdempotentParamExecuteHandler.java 3KB
RedisUtil.java 3KB
UserInfoController.java 3KB
TrainBusinessCheckSeat.java 3KB
ThreadFactoryBuilder.java 3KB
IdempotentAutoConfiguration.java 3KB
SnowflakeIdUtil.java 3KB
Assert.java 3KB
RedisConfig.java 3KB
TrainStationServiceImpl.java 3KB
TradeStatusEnum.java 3KB
DefaultServiceIdGenerator.java 3KB
GlobalExceptionHandler.java 3KB
TicketService.java 3KB
PayResultCallbackOrderConsumer.java 3KB
AbstractCommonSendProduceTemplate.java 3KB
CustomDbHashModShardingAlgorithm.java 3KB
IdempotentSpELByRestAPIExecuteHandler.java 3KB
IdempotentAspect.java 3KB
TempSeatController.java 3KB
JWTUtil.java 3KB
ChooseSeatUtil.java 3KB
DelayCloseOrderSendProduce.java 3KB
PayController.java 3KB
CacheAutoConfiguration.java 3KB
TicketOrderRemoteService.java 3KB
JWTUtil.java 3KB
CallBackServiceImpl.java 2KB
共 539 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
沐知全栈开发
- 粉丝: 5798
- 资源: 5226
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功