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
沐知全栈开发
- 粉丝: 5701
- 资源: 5215
最新资源
- 智能GPT图书管理系统,全局异常拦截器,登录校验拦截器,Echarts展示借阅量,可添加爬虫功能获取图书数据
- 基于树莓派+YOLOV5的识别模型实现四驱智能小车+项目源码+文档说明+数据集+模型
- 震撼市场潜力:预计2024年创新药市场规模将达到7534亿元,引领医药产业新变革
- chromedriver-132.0.6833.0-win64.zip
- 小六壬速断软件,根据农历月日时辰起卦,得三宫,算事业、算婚姻感情、算失物方位
- 微信小程序入门全流程解析-注册到发布实战指南
- winform,左侧工具栏,右上显示代码,下方显示曲线,曲线可以拖拽移动位置
- 安全与电磁兼容:精选文章引用格式汇总
- GIMP 3.0.0 RC1 MacOS 苹果芯片版本
- chromedriver-132.0.6834.3-win64.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈