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/  登录

运行截图

台界面

 

 

 

 

 

 

 

 后台页面

 

 

 代码相关

支付宝支付连接

@Controller
public class PayController {
    @Autowired
    private TMovieorderService tMovieorderService;

    private static String out_trade_no;

    @RequestMapping("/success")
    public String success(){
        //修改订单状态
        TMovieorder t=new TMovieorder();
        t.setOrderid(Integer.parseInt(out_trade_no));
        t.setStatus(1);
        tMovieorderService.update(t);
        return "redirect:/userorder/findorder?page=1&pagesize=2";
    }

    @RequestMapping("/pay")
    public void payController(HttpServletRequest request, HttpServletResponse response) throws IOException {

        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");

        //获得初始化的AlipayClient
        AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.gatewayUrl, AlipayConfig.app_id, AlipayConfig.merchant_private_key, "json", AlipayConfig.charset, AlipayConfig.alipay_public_key, AlipayConfig.sign_type);

        //设置请求参数
        AlipayTradePagePayRequest alipayRequest = new AlipayTradePagePayRequest();
        alipayRequest.setReturnUrl(AlipayConfig.return_url);
        alipayRequest.setNotifyUrl(AlipayConfig.notify_url);


        //商户订单号,商户网站订单系统中唯一订单号,必填
        out_trade_no = new String(request.getParameter("WIDout_trade_no").getBytes("ISO-8859-1"), "UTF-8");
        //付款金额,必填
        String total_amount = new String(request.getParameter("WIDtotal_amount").getBytes("ISO-8859-1"), "UTF-8");
        //订单名称,必填
        String subject = new String(request.getParameter("WIDsubject").getBytes("ISO-8859-1"), "UTF-8");
        //商品描述,可空
        String body = new String(request.getParameter("WIDbody").getBytes("ISO-8859-1"), "UTF-8");

        alipayRequest.setBizContent("{\"out_trade_no\":\"" + out_trade_no + "\","
                + "\"total_amount\":\"" + total_amount + "\","
                + "\"subject\":\"" + subject + "\","
                + "\"body\":\"" + body + "\","
                + "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}");

        //若想给BizContent增加其他可选请求参数,以增加自定义超时时间参数timeout_express来举例说明
        //alipayRequest.setBizContent("{\"out_trade_no\":\""+ out_trade_no +"\","
        //		+ "\"total_amount\":\""+ total_amount +"\","
        //		+ "\"subject\":\""+ subject +"\","
        //		+ "\"body\":\""+ body +"\","
        //		+ "\"timeout_express\":\"10m\","
        //		+ "\"product_code\":\"FAST_INSTANT_TRADE_PAY\"}");
        //请求参数可查阅【电脑网站支付的API文档-alipay.trade.page.pay-请求参数】章节

        //请求
        String form = "";
        try {
            form = alipayClient.pageExecute(alipayRequest).getBody(); //调用SDK生成表单
        } catch (AlipayApiException e) {
            e.printStackTrace();
        }
        response.setContentType("text/html;charset=" + AlipayConfig.charset);
        response.getWriter().write(form);//直接将完整的表单html输出到页面
        response.getWriter().flush();
        response.getWriter().close();
    }
}

订单管理控制器

@Controller
@RequestMapping("/userorder")
public class UserOrderController {
    @Autowired
    private TMovieorderService tMovieorderService;

    @Autowired
    private TUserinfoService tUserinfoService;

    @RequestMapping("/addajax")
    public @ResponseBody
            Msm addajax(Integer id){
        Msm byId = tMovieorderService.findById(id);
        System.out.println(id);
        return byId;
    }

    @RequestMapping("/add")
    public String add(Integer id,ModelMap modelMap){
        Msm byId = tMovieorderService.findById(id);
        modelMap.addAttribute("msm",byId);
        return "seat";
    }

    @RequestMapping("/buy")
    public String buy(Msm msm){
        tMovieorderService.insert(msm);
        System.out.println(msm);
        return "redirect:/userorder/findorder?page=1&pagesize=2";
    }

    @RequestMapping("/findorder")
    public String findByusername(int page,int pagesize,ModelMap modelMap){
        String name = SecurityContextHolder.getContext().getAuthentication().getName();
        TUserinfo userByname = tUserinfoService.findUserByname(name);
        Integer count = tMovieorderService.count(name);
        Page pagein=new Page();
        pagein.setPageSize(pagesize);
        pagein.setPage(page);
        pagein.setCount(count);
        List<TMovieorder> byUsername = tMovieorderService.findByUsername(name,page,pagesize);
        PageInfo pageInfo=new PageInfo(byUsername);
        modelMap.addAttribute("orders",pageInfo);
        modelMap.addAttribute("pages",pagein);
        modelMap.addAttribute("me",userByname);
        return "user_order";
    }

    @RequestMapping("/cancel")
    public String cancel(Integer orderid){
        TMovieorder t=new TMovieorder();
        t.setOrderid(orderid);
        t.setStatus(3);
        tMovieorderService.update(t);
        return "redirect:/userorder/findorder?page=1&pagesize=2";
    }
}

 电影实验层

@Service("tMoviehallService")
public class TMoviehallServiceImpl implements TMoviehallService {
    @Resource
    private TMoviehallDao tMoviehallDao;

    /**
     * 通过ID查询单条数据
     *
     * @param moviehallid 主键
     * @return 实例对象
     */
    @Override
    public TMoviehall queryById(Integer moviehallid) {
        return this.tMoviehallDao.queryById(moviehallid);
    }

    @Override
    public List<TMoviehall> findAll(TMoviehall tMoviehall) {
        return tMoviehallDao.queryAll(tMoviehall);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TMoviehall> queryAllByLimit(int offset, int limit) {
        return this.tMoviehallDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tMoviehall 实例对象
     * @return 实例对象
     */
    @Override
    public TMoviehall insert(TMoviehall tMoviehall) {
        this.tMoviehallDao.insert(tMoviehall);
        return tMoviehall;
    }

    /**
     * 修改数据
     *
     * @param tMoviehall 实例对象
     * @return 实例对象
     */
    @Override
    public TMoviehall update(TMoviehall tMoviehall) {
        this.tMoviehallDao.update(tMoviehall);
        return this.queryById(tMoviehall.getMoviehallid());
    }

    /**
     * 通过主键删除数据
     *
     * @param moviehallid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer moviehallid) {
        tMoviehallDao.deleteSC(moviehallid);
        return this.tMoviehallDao.deleteById(moviehallid) > 0;
    }


}

电影管理控制器

@Service("tMovieService")
public class TMovieServiceImpl implements TMovieService {
    @Resource
    private TMovieDao tMovieDao;
    @Autowired
    private TScheduleDao tScheduleDao;
    @Autowired
    private TScheduleService tScheduleService;
    @Autowired
    private TSortDao tSortDao;
    @Autowired
    private TCommentDao tCommentDao;
    /**
     * 通过ID查询单条数据
     *
     * @param movieid 主键
     * @return 实例对象
     */
    @Override
    public TMovie queryById(Integer movieid) {
        return tMovieDao.queryById(movieid);
    }


    /**
     * 新增数据
     *
     * @param tMovie 实例对象
     * @return 实例对象
     */
    @Override
    public TMovie insert(TMovie tMovie) {
        this.tMovieDao.insert(tMovie);
        System.out.println(tMovie);
        Integer[] sortid = tMovie.getSortid();
        for (Integer integer : sortid) {
            tSortDao.insertm_s(tMovie.getMovieid(),integer);
        }
        return tMovie;
    }

    /**
     * 修改数据
     *
     * @param tMovie 实例对象
     * @return 实例对象
     */
    @Override
    public void update(TMovie tMovie) {
        this.tMovieDao.update(tMovie);
    }

    @Override
    public void updateMs(TMovie tMovie) {
        Integer[] sortid = tMovie.getSortid();
        tSortDao.deleteByMid(tMovie.getMovieid());
        for (Integer integer : sortid) {
            tSortDao.insertm_s(tMovie.getMovieid(),integer);
        }
        this.tMovieDao.update(tMovie);
    }


    /**
     * 通过主键删除数据
     *
     * @param movieid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer movieid) {
        tScheduleService.deleteByMid(movieid);
        tSortDao.deleteByMid(movieid);
        tCommentDao.deleteByMid(movieid);
        return this.tMovieDao.deleteById(movieid) > 0;
    }

    @Override
    public List<TMovie> findall(int page, int pageSize) {
        PageHelper.startPage(page, pageSize);
        List<TMovie> movies = tMovieDao.findall();
        return movies;

    }

    @Override
    public List<TMovie> findall() {
        return tMovieDao.findall();

    }

    @Override
    public Integer findCount() {
        return tMovieDao.findCount();
    }

    /**
     *
     * @param sid 分类的id
     * @return 电影
     */
    @Override
    public List<TMovie> findBySortID(Integer sid) {
        return tMovieDao.findBySort(sid);
    }

    @Override
    public List<TMovie> findBYname(String name,Integer page ,Integer pagesize) {
        name="%"+name+"%";
        PageHelper.startPage(page,pagesize);
        return tMovieDao.findByname(name);
    }

    @Override
    public List<TSchedule> findByMid(Integer mid) {
        return tScheduleDao.findBymovieID(mid);
    }

    @Override
    public List<TSort> countHit() {
        return tMovieDao.countHit();
    }

    @Override
    public List<TMovie> findSome(TMovie tMovie, Integer page, Integer pageSize) {
        TSchedule tSchedule=new TSchedule();
        tSchedule.setScheduleid(111);
        tMovie.setMoviename("%"+tMovie.getMoviename()+"%");
        tMovie.setDirector("%"+tMovie.getDirector()+"%");
        tMovie.setMainperformer("%"+tMovie.getMainperformer()+"%");
        PageHelper.startPage(page,pageSize);
        List<TMovie> some = tMovieDao.findSome(tMovie);
        for (TMovie movie : some) {
            movie.settSchedule(tSchedule);
        }
        return some;
    }

    @Override
    public List<TMovie> tMovieTop() {
        return tMovieDao.tMovieTop();
    }

    @Override
    public List<TMovie> findBysort(Integer id) {
        return tMovieDao.findmoviesBySort(id);
    }

    @Override
    public List<TMovie> findBysort(Integer id, Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        return tMovieDao.findmoviesBySort(id);
    }

    @Override
    public List<TMovie> findTopBysort(Integer id,Integer start, Integer limit) {
        return tMovieDao.findTopBySort(id,start,limit);
    }

    @Override
    public Integer countSort(Integer sid) {
        return tMovieDao.countBysort(sid);
    }
}

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

  • 0
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜未央5788

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值