package com.movie.api.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.movie.api.constant.OrderStatus;
import com.movie.api.mapper.FilmMapper;
import com.movie.api.mapper.OrderMapper;
import com.movie.api.mapper.UserMapper;
import com.movie.api.model.entity.Arrangement;
import com.movie.api.model.entity.Cart;
import com.movie.api.model.entity.Film;
import com.movie.api.model.entity.Order;
import com.movie.api.model.vo.OrderVO;
import com.movie.api.service.ArrangementService;
import com.movie.api.service.OrderService;
import com.movie.api.utils.DataTimeUtil;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@Service
@CacheConfig(cacheNames = "order")
public class OrderServiceImpl implements OrderService {
@Resource
private OrderMapper orderMapper;
@Resource
private ArrangementService arrangementService;
@Resource
private UserMapper userMapper;
@Resource
private FilmMapper filmMapper;
@Override
public Order create(Cart cart) throws Exception {
List<Integer> seats = arrangementService.getSeatsHaveSelected(cart.getAid());
String[] split = cart.getSeats().split("号");
for (String s : split) {
if (seats.contains(Integer.parseInt(s))) throw new Exception("影片在购物车中躺了太长时间了,座位已被其他用户预订并支付了");
}
Order order = new Order();
//生成订单id
order.setId(UUID.randomUUID().toString());
//写入用户id
order.setUid(cart.getUid());
//写入用户电话
order.setPhone(cart.getPhone());
//写入场次id
order.setAid(cart.getAid());
//写入座位信息
order.setStatus(cart.getStatus());
order.setSeats(cart.getSeats());
if (cart.getStatus() == 2) order.setPayAt(DataTimeUtil.getNowTimeString());
order.setPrice(cart.getPrice());
order.setCreateAt(DataTimeUtil.getNowTimeString());
orderMapper.insert(order);
//订了几个座位就添加多少热度
Film film = filmMapper.selectById(arrangementService.findById(cart.getAid()).getFid());
film.setHot(film.getHot() + split.length);
filmMapper.updateById(film);
return order;
}
@Override
public Order pay(String id) throws Exception {
Order order = orderMapper.selectById(id);
if (order == null) throw new Exception("不存在的订单id");
if (DataTimeUtil.parseTimeStamp(order.getCreateAt()) + OrderStatus.EXPIRATION_TIME
< System.currentTimeMillis()) {
order.setStatus(OrderStatus.PAYMENT_FAILED);
orderMapper.updateById(order);
throw new Exception("订单支付超时");
}
order.setStatus(OrderStatus.PAYMENT_SUCCESSFUL);
order.setPayAt(DataTimeUtil.getNowTimeString());
orderMapper.updateById(order);
return order;
}
@Override
public void update(Order order) {
orderMapper.updateById(order);
}
@Override
public List<OrderVO> findAll() {
return findByWrapper(new QueryWrapper<>());
}
@Override
public List<OrderVO> findByUser(String uid) {
QueryWrapper<Order> wrapper = new QueryWrapper<>();
wrapper.in("uid", uid);
return findByWrapper(wrapper);
}
private List<OrderVO> findByWrapper(QueryWrapper<Order> wrapper) {
List<Order> orders = orderMapper.selectList(wrapper);
List<OrderVO> result = new ArrayList<>();
for (Order o : orders) {
OrderVO orderVO = new OrderVO();
orderVO.setOrder(o);
orderVO.setUser(userMapper.selectById(o.getUid()));
Arrangement arrangement = arrangementService.findById(o.getAid());
orderVO.setArrangement(arrangement);
orderVO.setFilm(filmMapper.selectById(arrangement.getFid()));
result.add(orderVO);
}
return result;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于SpringBoot+MyBatis-Plus+Vue+element ui的前后端分离的影院选座购票系统源码.zip个人经导师指导并认可通过的高分毕业设计项目,评审分98分。主要针对计算机相关专业的正在做毕设的学生和需要项目实战练习的学习者,也可作为课程设计、期末大作业。 基于SpringBoot+MyBatis-Plus+Vue+element ui的前后端分离的影院选座购票系统源码.zip基于SpringBoot+MyBatis-Plus+Vue+element ui的前后端分离的影院选座购票系统源码.zip基于SpringBoot+MyBatis-Plus+Vue+element ui的前后端分离的影院选座购票系统源码.zip基于SpringBoot+MyBatis-Plus+Vue+element ui的前后端分离的影院选座购票系统源码.zip基于SpringBoot+MyBatis-Plus+Vue+element ui的前后端分离的影院选座购票系统源码.zip基于SpringBoot+MyBatis-Plus+Vue+element ui的前后端分离的影院选座购票
资源推荐
资源详情
资源评论
收起资源包目录
基于SpringBoot+MyBatis-Plus+Vue+element ui的前后端分离的影院选座购票系统源码.zip (121个子文件)
.gitignore 5B
api.iml 10KB
OrderServiceImpl.java 4KB
WorkerServiceImpl.java 3KB
SecurityConfiguration.java 3KB
UploadController.java 3KB
FilmEvaluateServiceImpl.java 2KB
WorkerController.java 2KB
UserServiceImpl.java 2KB
JwtTokenUtil.java 2KB
AuthorizationFilter.java 2KB
CartServiceImpl.java 2KB
LeavingMessageServiceImpl.java 2KB
ArrangementServiceImpl.java 2KB
RegistrationServiceImpl.java 2KB
ArrangementController.java 2KB
FilmServiceImpl.java 2KB
UserController.java 2KB
RoleServiceImpl.java 2KB
FilmController.java 2KB
UploadServiceImpl.java 2KB
RoleController.java 1KB
WorkerEvaluateServiceImpl.java 1KB
OrderController.java 1KB
FilmEvaluateController.java 1KB
PosterController.java 1KB
GlobalResponseHandler.java 1KB
PosterServiceImpl.java 1KB
LeavingMessageController.java 1KB
OrderExceptionServiceImpl.java 1KB
AdminServiceImpl.java 1KB
ActivityController.java 1KB
OrderExceptionController.java 1KB
ResponseUtil.java 1KB
GlobalExceptionHandler.java 1KB
WorkerEvaluateController.java 1KB
ResponseResult.java 1KB
ActivityServiceImpl.java 1012B
CartController.java 990B
SwaggerConfiguration.java 990B
DailyWorkController.java 978B
Arrangement.java 973B
DataTimeUtil.java 949B
Roles.java 917B
DailyWorkServiceImpl.java 917B
RegistrationController.java 865B
Film.java 796B
AdminController.java 787B
User.java 746B
Order.java 709B
Worker.java 693B
OrderException.java 691B
WorkerEvaluate.java 556B
Cart.java 532B
FilmEvaluate.java 525B
CartService.java 507B
OrderStatus.java 506B
LeavingMessageService.java 494B
FilmService.java 486B
ArrangementService.java 483B
ApiApplication.java 473B
Activity.java 472B
LeavingMessage.java 470B
FilmEvaluateVO.java 465B
Admin.java 457B
Role.java 452B
Upload.java 451B
DailyWork.java 437B
CartVO.java 437B
UserService.java 427B
WorkerService.java 423B
OrderService.java 407B
WorkerEvaluateService.java 405B
Poster.java 399B
Registration.java 396B
LeavingMessageVO.java 385B
FilmEvaluateService.java 382B
OrderVO.java 366B
DisableBaseResponse.java 338B
PosterService.java 332B
WorkerEvaluateVO.java 331B
ArrangementVO.java 326B
RoleService.java 320B
RegistrationService.java 316B
OrderExceptionService.java 305B
ActiveUserVO.java 290B
FilmStatus.java 275B
ActivityService.java 275B
UploadService.java 271B
LeavingMessageMapper.java 268B
WorkerEvaluateMapper.java 268B
FilmEvaluateMapper.java 262B
OrderExceptionMapper.java 252B
RegistrationMapper.java 246B
WorkerMapper.java 244B
UploadMapper.java 244B
ArrangementMapper.java 243B
DailyWorkService.java 243B
OrderMapper.java 241B
AdminMapper.java 241B
共 121 条
- 1
- 2
资源评论
程序员张小妍
- 粉丝: 1w+
- 资源: 3474
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于二阶自抗扰ADRC的轨迹跟踪控制,对车辆的不确定性和外界干扰具有一定抗干扰性,基于carsim和simulink仿真 跟踪轨迹为双移线,效果良好,有对应复现资料,是学习自抗扰技术快速入门很好的资料
- 基于python的网页自动化工具项目全套技术资料100%好用.zip
- MATLAB【逆变器二次调频模型】 微电网分布式电源逆变器DROOP控制二次调频模型,加入二次控制实现二次调频控制,及二次调压控制,程序可实现上图功能,工况有所改变 需要matlab2021A版
- 抢购软件:快速复制信息
- 单机无穷大系统发生各类(三相短路,单相接地,两相接地,两相相间短路)等短路故障,各类(单相断线,两相断线,三相断线)等断线故障,暂态稳定仿真分析
- 微信文章爬虫项目全套技术资料100%好用.zip
- 基于动态窗口算法的AGV仿真避障 可设置起点目标点,设置地图,设置移动障碍物起始点目标点,未知静态障碍物 动态窗口方法(DynamicWindowApproach) 是一种可以实现实时避障的局部规划算
- Power Quality Disturbance:基于MATLAB Simulink的各种电能质量扰动仿真模型,包括配电线路故障、感应电机启动、变压器励磁、单相 三相非线性负载等模型,可用于模拟各种
- 数据爬虫项目全套技术资料100%好用.zip
- 聊天系统项目全套技术资料100%好用.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功