• Java项目:ssm电影院购票系统


    作者主页:夜未央5788

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    影院购票系统,本项目分为前台和后台,用户有普通用户和管理员,普通用户只可访问前台页面,管理员可以访问后台;
    前台主要功能:

    电影分类、电影排行、电影详细介绍、选座购票、评论等功能;

    后台主要功能:

    用户管理、电影管理、订单管理、评论管理、标签管理、放映厅管理、场次安排等功能。

    环境需要

    1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
    2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
    3.tomcat环境:Tomcat 8.x,9.x版本均可  注:不可使用tomcat7.0,会造成图片显示异常等问题;
    4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
    5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 
    6.数据库:MySql 5.7版本;

    技术栈

    1. 后端:spring + spring mvc + mybatis + spring security 
    2. 前端:JSP+jQuery+bootstrap+layui+echarts

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2. 将项目中applicationContext.xml配置文件中的数据库配置改为自己的配置;
    3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

    若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
    4. 运行项目,在浏览器中输入http://localhost:8080/  登录

    运行截图

    台界面

     

     

     

     

     

     

     

     后台页面

     

     

     代码相关

    支付宝支付连接

    1. @Controller
    2. public class PayController {
    3. @Autowired
    4. private TMovieorderService tMovieorderService;
    5. private static String out_trade_no;
    6. @RequestMapping("/success")
    7. public String success(){
    8. //修改订单状态
    9. TMovieorder t=new TMovieorder();
    10. t.setOrderid(Integer.parseInt(out_trade_no));
    11. t.setStatus(1);
    12. tMovieorderService.update(t);
    13. return "redirect:/userorder/findorder?page=1&pagesize=2";
    14. }
    15. @RequestMapping("/pay")
    16. public void payController(HttpServletRequest request, HttpServletResponse response) throws IOException {
    17. request.setCharacterEncoding("utf-8");
    18. response.setContentType("text/html;charset=utf-8");
    19. //获得初始化的AlipayClient
    20. AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, "json", AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type);
    21. //设置请求参数
    22. AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();
    23. alipayRequest.setReturnUrl(AlipayConfig.return_url);
    24. alipayRequest.setNotifyUrl(AlipayConfig.notify_url);
    25. //商户订单号,商户网站订单系统中唯一订单号,必填
    26. out_trade_no = new String(request.getParameter("WIDout_trade_no").getBytes("ISO-8859-1"), "UTF-8");
    27. //付款金额,必填
    28. String total_amount = new String(request.getParameter("WIDtotal_amount").getBytes("ISO-8859-1"), "UTF-8");
    29. //订单名称,必填
    30. String subject = new String(request.getParameter("WIDsubject").getBytes("ISO-8859-1"), "UTF-8");
    31. //商品描述,可空
    32. String body = new String(request.getParameter("WIDbody").getBytes("ISO-8859-1"), "UTF-8");
    33. alipayRequest.setBizContent("{\"out_trade_no\":\"" + out_trade_no + "\","
    34. + "\"total_amount\":\"" + total_amount + "\","
    35. + "\"subject\":\"" + subject + "\","
    36. + "\"body\":\"" + body + "\","
    37. + "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}");
    38. //若想给BizContent增加其他可选请求参数,以增加自定义超时时间参数timeout_express来举例说明
    39. //alipayRequest.setBizContent("{\"out_trade_no\":\""+ out_trade_no +"\","
    40. // + "\"total_amount\":\""+ total_amount +"\","
    41. // + "\"subject\":\""+ subject +"\","
    42. // + "\"body\":\""+ body +"\","
    43. // + "\"timeout_express\":\"10m\","
    44. // + "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}");
    45. //请求参数可查阅【电脑网站支付的API文档-alipay.trade.page.pay-请求参数】章节
    46. //请求
    47. String form = "";
    48. try {
    49. form = alipayClient.pageExecute(alipayRequest).getBody(); //调用SDK生成表单
    50. } catch (AlipayApiException e) {
    51. e.printStackTrace();
    52. }
    53. response.setContentType("text/html;charset=" + AlipayConfig.charset);
    54. response.getWriter().write(form);//直接将完整的表单html输出到页面
    55. response.getWriter().flush();
    56. response.getWriter().close();
    57. }
    58. }

    订单管理控制器

    1. @Controller
    2. @RequestMapping("/userorder")
    3. public class UserOrderController {
    4. @Autowired
    5. private TMovieorderService tMovieorderService;
    6. @Autowired
    7. private TUserinfoService tUserinfoService;
    8. @RequestMapping("/addajax")
    9. public @ResponseBody
    10. Msm addajax(Integer id){
    11. Msm byId = tMovieorderService.findById(id);
    12. System.out.println(id);
    13. return byId;
    14. }
    15. @RequestMapping("/add")
    16. public String add(Integer id,ModelMap modelMap){
    17. Msm byId = tMovieorderService.findById(id);
    18. modelMap.addAttribute("msm",byId);
    19. return "seat";
    20. }
    21. @RequestMapping("/buy")
    22. public String buy(Msm msm){
    23. tMovieorderService.insert(msm);
    24. System.out.println(msm);
    25. return "redirect:/userorder/findorder?page=1&pagesize=2";
    26. }
    27. @RequestMapping("/findorder")
    28. public String findByusername(int page,int pagesize,ModelMap modelMap){
    29. String name = SecurityContextHolder.getContext().getAuthentication().getName();
    30. TUserinfo userByname = tUserinfoService.findUserByname(name);
    31. Integer count = tMovieorderService.count(name);
    32. Page pagein=new Page();
    33. pagein.setPageSize(pagesize);
    34. pagein.setPage(page);
    35. pagein.setCount(count);
    36. List byUsername = tMovieorderService.findByUsername(name,page,pagesize);
    37. PageInfo pageInfo=new PageInfo(byUsername);
    38. modelMap.addAttribute("orders",pageInfo);
    39. modelMap.addAttribute("pages",pagein);
    40. modelMap.addAttribute("me",userByname);
    41. return "user_order";
    42. }
    43. @RequestMapping("/cancel")
    44. public String cancel(Integer orderid){
    45. TMovieorder t=new TMovieorder();
    46. t.setOrderid(orderid);
    47. t.setStatus(3);
    48. tMovieorderService.update(t);
    49. return "redirect:/userorder/findorder?page=1&pagesize=2";
    50. }
    51. }

     电影实验层

    1. @Service("tMoviehallService")
    2. public class TMoviehallServiceImpl implements TMoviehallService {
    3. @Resource
    4. private TMoviehallDao tMoviehallDao;
    5. /**
    6. * 通过ID查询单条数据
    7. *
    8. * @param moviehallid 主键
    9. * @return 实例对象
    10. */
    11. @Override
    12. public TMoviehall queryById(Integer moviehallid) {
    13. return this.tMoviehallDao.queryById(moviehallid);
    14. }
    15. @Override
    16. public List findAll(TMoviehall tMoviehall) {
    17. return tMoviehallDao.queryAll(tMoviehall);
    18. }
    19. /**
    20. * 查询多条数据
    21. *
    22. * @param offset 查询起始位置
    23. * @param limit 查询条数
    24. * @return 对象列表
    25. */
    26. @Override
    27. public List queryAllByLimit(int offset, int limit) {
    28. return this.tMoviehallDao.queryAllByLimit(offset, limit);
    29. }
    30. /**
    31. * 新增数据
    32. *
    33. * @param tMoviehall 实例对象
    34. * @return 实例对象
    35. */
    36. @Override
    37. public TMoviehall insert(TMoviehall tMoviehall) {
    38. this.tMoviehallDao.insert(tMoviehall);
    39. return tMoviehall;
    40. }
    41. /**
    42. * 修改数据
    43. *
    44. * @param tMoviehall 实例对象
    45. * @return 实例对象
    46. */
    47. @Override
    48. public TMoviehall update(TMoviehall tMoviehall) {
    49. this.tMoviehallDao.update(tMoviehall);
    50. return this.queryById(tMoviehall.getMoviehallid());
    51. }
    52. /**
    53. * 通过主键删除数据
    54. *
    55. * @param moviehallid 主键
    56. * @return 是否成功
    57. */
    58. @Override
    59. public boolean deleteById(Integer moviehallid) {
    60. tMoviehallDao.deleteSC(moviehallid);
    61. return this.tMoviehallDao.deleteById(moviehallid) > 0;
    62. }
    63. }

    电影管理控制器

    1. @Service("tMovieService")
    2. public class TMovieServiceImpl implements TMovieService {
    3. @Resource
    4. private TMovieDao tMovieDao;
    5. @Autowired
    6. private TScheduleDao tScheduleDao;
    7. @Autowired
    8. private TScheduleService tScheduleService;
    9. @Autowired
    10. private TSortDao tSortDao;
    11. @Autowired
    12. private TCommentDao tCommentDao;
    13. /**
    14. * 通过ID查询单条数据
    15. *
    16. * @param movieid 主键
    17. * @return 实例对象
    18. */
    19. @Override
    20. public TMovie queryById(Integer movieid) {
    21. return tMovieDao.queryById(movieid);
    22. }
    23. /**
    24. * 新增数据
    25. *
    26. * @param tMovie 实例对象
    27. * @return 实例对象
    28. */
    29. @Override
    30. public TMovie insert(TMovie tMovie) {
    31. this.tMovieDao.insert(tMovie);
    32. System.out.println(tMovie);
    33. Integer[] sortid = tMovie.getSortid();
    34. for (Integer integer : sortid) {
    35. tSortDao.insertm_s(tMovie.getMovieid(),integer);
    36. }
    37. return tMovie;
    38. }
    39. /**
    40. * 修改数据
    41. *
    42. * @param tMovie 实例对象
    43. * @return 实例对象
    44. */
    45. @Override
    46. public void update(TMovie tMovie) {
    47. this.tMovieDao.update(tMovie);
    48. }
    49. @Override
    50. public void updateMs(TMovie tMovie) {
    51. Integer[] sortid = tMovie.getSortid();
    52. tSortDao.deleteByMid(tMovie.getMovieid());
    53. for (Integer integer : sortid) {
    54. tSortDao.insertm_s(tMovie.getMovieid(),integer);
    55. }
    56. this.tMovieDao.update(tMovie);
    57. }
    58. /**
    59. * 通过主键删除数据
    60. *
    61. * @param movieid 主键
    62. * @return 是否成功
    63. */
    64. @Override
    65. public boolean deleteById(Integer movieid) {
    66. tScheduleService.deleteByMid(movieid);
    67. tSortDao.deleteByMid(movieid);
    68. tCommentDao.deleteByMid(movieid);
    69. return this.tMovieDao.deleteById(movieid) > 0;
    70. }
    71. @Override
    72. public List findall(int page, int pageSize) {
    73. PageHelper.startPage(page, pageSize);
    74. List movies = tMovieDao.findall();
    75. return movies;
    76. }
    77. @Override
    78. public List findall() {
    79. return tMovieDao.findall();
    80. }
    81. @Override
    82. public Integer findCount() {
    83. return tMovieDao.findCount();
    84. }
    85. /**
    86. *
    87. * @param sid 分类的id
    88. * @return 电影
    89. */
    90. @Override
    91. public List findBySortID(Integer sid) {
    92. return tMovieDao.findBySort(sid);
    93. }
    94. @Override
    95. public List findBYname(String name,Integer page ,Integer pagesize) {
    96. name="%"+name+"%";
    97. PageHelper.startPage(page,pagesize);
    98. return tMovieDao.findByname(name);
    99. }
    100. @Override
    101. public List findByMid(Integer mid) {
    102. return tScheduleDao.findBymovieID(mid);
    103. }
    104. @Override
    105. public List countHit() {
    106. return tMovieDao.countHit();
    107. }
    108. @Override
    109. public List findSome(TMovie tMovie, Integer page, Integer pageSize) {
    110. TSchedule tSchedule=new TSchedule();
    111. tSchedule.setScheduleid(111);
    112. tMovie.setMoviename("%"+tMovie.getMoviename()+"%");
    113. tMovie.setDirector("%"+tMovie.getDirector()+"%");
    114. tMovie.setMainperformer("%"+tMovie.getMainperformer()+"%");
    115. PageHelper.startPage(page,pageSize);
    116. List some = tMovieDao.findSome(tMovie);
    117. for (TMovie movie : some) {
    118. movie.settSchedule(tSchedule);
    119. }
    120. return some;
    121. }
    122. @Override
    123. public List tMovieTop() {
    124. return tMovieDao.tMovieTop();
    125. }
    126. @Override
    127. public List findBysort(Integer id) {
    128. return tMovieDao.findmoviesBySort(id);
    129. }
    130. @Override
    131. public List findBysort(Integer id, Integer page, Integer pageSize) {
    132. PageHelper.startPage(page,pageSize);
    133. return tMovieDao.findmoviesBySort(id);
    134. }
    135. @Override
    136. public List findTopBysort(Integer id,Integer start, Integer limit) {
    137. return tMovieDao.findTopBySort(id,start,limit);
    138. }
    139. @Override
    140. public Integer countSort(Integer sid) {
    141. return tMovieDao.countBysort(sid);
    142. }
    143. }

    如果也想学习本系统,下面领取。回复:010ssm 

  • 相关阅读:
    “灯塔工厂”的中国路径:智造从点到面铺开
    软考考后常见问题详解~
    WPF绘图(图形的效果与变形)
    MySQL中查询重复字段的方法和步骤是怎样
    C++通过VS2022使用Conan2.0安装fmt库实现控制台彩色打印
    sed使用技巧-在replacement块获取pattern匹配的值
    房屋信贷违约风险竞争(kaggle)系列1-数据源介绍
    dlopen No such file or directory
    Android Studio compose的简单使用与案例实现
    ssm教务系统网站 毕业设计-附源码290915
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126024236