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
UploadMapper.java 244B
WorkerMapper.java 244B
ArrangementMapper.java 243B
DailyWorkService.java 243B
OrderMapper.java 241B
AdminMapper.java 241B
共 121 条
- 1
- 2
资源评论
程序员张小妍
- 粉丝: 1w+
- 资源: 3252
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于SimPy和贝叶斯优化的流程仿真系统.zip
- (源码)基于Java Web的个人信息管理系统.zip
- (源码)基于C++和OTL4的PostgreSQL数据库连接系统.zip
- (源码)基于ESP32和AWS IoT Core的室内温湿度监测系统.zip
- (源码)基于Arduino的I2C协议交通灯模拟系统.zip
- coco.names 文件
- (源码)基于Spring Boot和Vue的房屋租赁管理系统.zip
- (源码)基于Android的饭店点菜系统.zip
- (源码)基于Android平台的权限管理系统.zip
- (源码)基于CC++和wxWidgets框架的LEGO模型火车控制系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功