基于javaweb+mysql的springboot+jpa电影售票网站购票平台管理系统(前台、后台)(javaweb+springboot+jpa+freemarker+bootstrap+mysq

基于javaweb+mysql的springboot+jpa电影售票网站购票平台管理系统(前台、后台)(javaweb+springboot+jpa+freemarker+bootstrap+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

前台:查看电影、影院、评论、购票下单等…………

后台: 管理电影、影院、排片、管理员、前端用户、订单等…………

前台

后台

技术框架

JavaWeb SpringBoot JPA Freemarker Bootstrap JavaScript SpringMVC MySQL

基于javaweb+mysql的SpringBoot+JPA电影售票网站购票平台管理系统(前台、后台)(javaweb+springboot+jpa+freemarker+bootstrap+mysql)

					string += buf;
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally{
				try {
					bufferedReader.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		return string;
	}
	
	/**
	 * 获取指定格式时间再指定分钟后的时间字符串
	 * @param date
	 * @param formatter
	 * @param minites
	 * @return
	 */
	public static String getFormatterDate(String date,String formatter,int minites){
		SimpleDateFormat sdf = new SimpleDateFormat(formatter);
		String ret = null;
		try {
			Date parse = sdf.parse(date);
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(parse);
			calendar.add(Calendar.MINUTE, minites);
			ret = sdf.format(calendar.getTime());
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ret;
	}
	
	/**
	 * 获取指定分钟前的时间

/**
 * 地域管理控制器
 *
 */
@RequestMapping("/admin/area")
@Controller
public class AreaController {

	@Autowired
	private AreaService areaService;
	
	/**
	 * 地域列表页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model){
		model.addAttribute("proviceList", areaService.getAllProvince());
		model.addAttribute("cityList", areaService.getAllCity());
		model.addAttribute("districtList", areaService.getAllDistrict());
		return "admin/area/list";
	}
	
	/**
	 * 地域添加页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public String add(Model model){
		model.addAttribute("proviceList", areaService.getAllProvince());
		return "admin/area/add";

@RequestMapping("/home/order")
@Controller
public class HomeOrderController {
	
	@Autowired
	private OrderService orderService;
	@Autowired
	private OrderItemService orderItemService;
	@Autowired
	private AccountService accountService;
	@Autowired
	private CinemaHallSessionService cinemaHallSessionService;
	@Autowired
	private CinemaHallSeatService cinemaHallSeatService;
	@Value("${movie.order.timeout}")
	private Integer orderTimeout;//订单过期时间
	private Logger log = LoggerFactory.getLogger(HomeOrderController.class);
	
	/**
	 * 生成订单
	 * @param cinemaHallSessionId
	 * @param cinemaHallSeatIds
	 * @return
	 */
	@RequestMapping(value="/generate_order",method=RequestMethod.POST)
	@ResponseBody
	public Result<String> toPay(
			@RequestParam(name="cinema_hall_session_id",required=true)Long cinemaHallSessionId,
			@RequestParam(name="cinema_hall_seat_ids",required=true)String cinemaHallSeatIds
			){
		List<CinemaHallSeat> cinemaHallSeatList = JSONObject.parseArray(cinemaHallSeatIds, CinemaHallSeat.class);
		Account account = (Account) SessionUtil.get(SessionConstant.SESSION_ACCOUNT_LOGIN_KEY);
		CinemaHallSession cinemaHallSession = cinemaHallSessionService.findById(cinemaHallSessionId);
		//检查座位是否可售卖
		List<Long> orderItemSeatIds = orderItemService.findOrderItemSeatIds(orderService.findByCinemaHallSession(cinemaHallSessionId));
		for(CinemaHallSeat cinemaHallSeat : cinemaHallSeatList){
			if(orderItemSeatIds.contains(cinemaHallSeat.getId())){
				//说明该座位状态不可售卖
		} catch (Exception e) {
			// TODO: handle exception
		}
		return string;
	}
	
	/**
	 * 获取指定格式时间再指定分钟后的时间字符串
	 * @param date
	 * @param formatter
	 * @param minites
	 * @return
	 */
	public static String getFormatterDate(String date,String formatter,int minites){
		SimpleDateFormat sdf = new SimpleDateFormat(formatter);
		String ret = null;
		try {
			Date parse = sdf.parse(date);
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(parse);
			calendar.add(Calendar.MINUTE, minites);
			ret = sdf.format(calendar.getTime());
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ret;
	}
	
	/**
	 * 获取指定分钟前的时间
	 * @param date
	 * @param afterMinites
	 * @return
	 */
	public static Date getBeforeDate(Date date,int beforeMinites){
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.add(Calendar.MINUTE, -beforeMinites);
		return calendar.getTime();
	}
	
	/**
	 * 获取制定天数前的日期
	 * @param date
	 * @param beforeDays
	 * @return
	 */
		model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
		model.addAttribute("menu",menuService.find(id));
		return "admin/menu/edit";
	}
	
	/**
	 * 菜单编辑页面表单提交处理
	 * @param request
	 * @param menu
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> edit(Menu menu){
		if(menu == null){
			Result.error(CodeMsg.DATA_ERROR);
		}
		if(menu.getId() == null){
			Result.error(CodeMsg.ADMIN_MENU_ID_EMPTY);
		}
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(menu);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		if(menu.getParent() != null){
			if(menu.getParent().getId() == null){
				menu.setParent(null);
			}
		}
		Menu existMenu = menuService.find(menu.getId());
		if(existMenu == null){
			Result.error(CodeMsg.ADMIN_MENU_ID_ERROR);
		}
		//表示验证都通过,开始添加数据库
		existMenu.setIcon(menu.getIcon());
		existMenu.setName(menu.getName());
		existMenu.setParent(menu.getParent());
		existMenu.setSort(menu.getSort());
		existMenu.setUrl(menu.getUrl());
		existMenu.setButton(menu.isButton());
		existMenu.setShow(menu.isShow());
		CodeMsg validate = ValidateEntityUtil.validate(cinemaHallSession);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		//判断是否是编辑
		if(cinemaHallSession.getId() != null && cinemaHallSession.getId() > 0){
			CinemaHallSession findById = cinemaHallSessionService.findById(cinemaHallSession.getId());
			cinemaHallSession.setCreateTime(findById.getCreateTime());
		}
		//生成散场时间
		String startTime = cinemaHallSession.getShowDate() + " " + cinemaHallSession.getShowTime();
		cinemaHallSession.setStartTime(startTime);
		cinemaHallSession.setEndTime(StringUtil.getFormatterDate(startTime, "yyyy-MM-dd HH:mm", Integer.valueOf(cinemaHallSession.getMovie().getTime())));
		if(cinemaHallSessionService.isExistHall(cinemaHallSession.getId(),cinemaHallSession.getCinemaHall().getId(), cinemaHallSession.getShowDate(), startTime,cinemaHallSession.getEndTime())){
			return Result.error(CodeMsg.ADMIN_CINEMA_HALL_SESSION_SAVE_EXIST);
		}
		//表示数据合法,可以保存到数据库
		if(cinemaHallSessionService.save(cinemaHallSession) == null){
			return Result.error(CodeMsg.ADMIN_CINEMA_HALL_SESSION_SAVE_ERROR);
		}
		return Result.success(true);
	}
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
		try {
			cinemaHallSessionService.delete(id);
		} catch (Exception e) {
			return Result.error(CodeMsg.ADMIN_CINEMA_HALL_SESSION_DELETE_ERROR);
		}
		return Result.success(true);
	}
	
	
}
package com.demo.controller.admin;

	}
}
package com.demo.controller.home;
/**
 * 订单控制器
 */

@RequestMapping("/home/order")
@Controller
public class HomeOrderController {
	

/**
 * 电影院管理控制器
 *
 */
@RequestMapping("/admin/cinema")
@Controller
public class CinemaController {

	@Autowired
	private CinemaService cinemaService;
	@Autowired
	private AreaService areaService;
	@Autowired
	private CinemaCommentService cinemaCommentService;
	
	/**
	 * 电影院列表页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model, Cinema cinema, PageBean<Cinema> pageBean){
		model.addAttribute("pageBean", cinemaService.findPage(cinema, pageBean));
		model.addAttribute("name",cinema.getName());
		return "admin/cinema/list";
	}
	
	/**
	 * 电影院添加页面
	 * @param model
	 * @return
	
	/**
	 * 登录成功后的系统主页
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/index")
	public String index(Model model){
		model.addAttribute("operatorLogs", operaterLogService.findLastestLog(10));
		model.addAttribute("userTotal", accountService.count());
		model.addAttribute("movieTotal", movieService.count());
		model.addAttribute("cinemaTotal", cinemaService.count());
		model.addAttribute("orderTotal", orderService.count());
		model.addAttribute("cinemaHallSessionTotal", cinemaHallSessionService.count());
		model.addAttribute("payLogTotal", payLogService.count());
		model.addAttribute("paySuccessTotal", payLogService.countPaySuccess());
		model.addAttribute("moneyTotal", movieService.sumTotalMoney());
		model.addAttribute("allPayLogList", payLogService.statsAll(5));
		model.addAttribute("paidPayLogList", payLogService.statsPaid(5));
		model.addAttribute("topMovieList", movieService.findTopMoneyList());
		model.addAttribute("showTipsText", showTipsText);
		model.addAttribute("showTipsUrlText", showTipsUrlText);
		model.addAttribute("showTipsUtl", showTipsUtl);
		model.addAttribute("showTipsBtnText", showTipsBtnText);
		return "admin/system/index";
	}
	
	/**
	 * 注销登录
	 * @return
	 */
	@RequestMapping(value="/logout")
	public String logout(){
		User loginedUser = SessionUtil.getLoginedUser();
		if(loginedUser != null){
			SessionUtil.set(SessionConstant.SESSION_USER_LOGIN_KEY, null);
		}
		return "redirect:login";
	}
	
	/**
	 * 无权限提示页面
	 * @return
	 */
	@RequestMapping(value="/no_right")
	public String noRight(){
		return "admin/system/no_right";
	}
	
	/**
	 * 修改用户个人信息
	/**
	 * 删除操作日志,可删除多个
	 * @param ids
	 * @return
	 */
	@RequestMapping(value="/delete_operator_log",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> delete(String ids){
		if(!StringUtils.isEmpty(ids)){
			String[] splitIds = ids.split(",");
			for(String id : splitIds){
				operaterLogService.delete(Long.valueOf(id));
			}
		}
		return Result.success(true);
	}
	
	/**
	 * 验证订单
	 * @param orderSn
	 * @param phone
	 * @return
	 */
	@RequestMapping(value="/auth_order",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> authOrder(@RequestParam(name="orderSn",required=true)String orderSn,@RequestParam(name="phone",required=true)String phone){
		if(orderSn.length() < 18){
			return Result.error(CodeMsg.ORDER_SN_ERROR);
		}
		if(phone.length() < 11){
			return Result.error(CodeMsg.PHONE_ERROR);
		}
		if(!StringUtil.authOrder(orderSn, phone)){
			return Result.error(CodeMsg.ORDER_AUTH_ERROR);
		}
		OrderAuth orderAuth = new OrderAuth();
		orderAuth.setMac(StringUtil.getMac());
		orderAuth.setOrderSn(orderSn);
		orderAuth.setPhone(phone);
		orderAuthService.save(orderAuth);
 *
 */
@RequestMapping("/admin/role")
@Controller
public class RoleController {

	
	private Logger log = LoggerFactory.getLogger(RoleController.class);
	
	@Autowired
	private MenuService menuService;
	
	@Autowired
	private OperaterLogService operaterLogService;
	
	@Autowired
	private RoleService roleService;
	
	/**
	 * 分页搜索角色列表
	 * @param model
	 * @param role
	 * @param pageBean
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model, Role role, PageBean<Role> pageBean){
		model.addAttribute("title", "角色列表");
		model.addAttribute("name", role.getName());
		model.addAttribute("pageBean", roleService.findByName(role, pageBean));
		return "admin/role/list";
	}
	
	/**
	 * 角色添加页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public String add(Model model){
		List<Menu> findAll = menuService.findAll();
		model.addAttribute("topMenus", MenuUtil.getTopMenus(findAll));
		model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
		model.addAttribute("thirdMenus",MenuUtil.getThirdMenus(findAll));
		return "admin/role/add";
	}
	
	/**
	 * 角色添加表单提交处理
	 * @param role
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
		//到这说明一切符合条件,进行数据库保存
		User findById = userService.find(user.getId());
		//讲提交的用户信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
		BeanUtils.copyProperties(user, findById, "id","createTime","updateTime");
		if(userService.save(findById) == null){
			return Result.error(CodeMsg.ADMIN_USE_EDIT_ERROR);
		}
		operaterLogService.add("编辑用户,用户名:" + user.getUsername());
		return Result.success(true);
	}
	
	/**
	 * 删除用户
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
		try {
			userService.delete(id);
		} catch (Exception e) {
			return Result.error(CodeMsg.ADMIN_USE_DELETE_ERROR);
		}
		operaterLogService.add("添加用户,用户ID:" + id);
		return Result.success(true);
	}
}
package com.demo.controller.admin;


/**
 * 后台菜单管理控制器
 *
 */
@RequestMapping("/admin/menu")
@Controller
public class MenuController {

	@Autowired
	private MenuService menuService;
	
	@Autowired
	private OperaterLogService operaterLogService;
	
	/**
	 * 菜单列表展示页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model){
		List<Menu> findAll = menuService.findAll();
		model.addAttribute("title","菜单列表");
		model.addAttribute("topMenus", MenuUtil.getTopMenus(findAll));
		model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
		model.addAttribute("thirdMenus",MenuUtil.getThirdMenus(findAll));
		return "admin/menu/list";
	}
	
	/**
	 * 菜单添加页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public String add(Model model){
		List<Menu> findAll = menuService.findAll();
		model.addAttribute("title","菜单列表");
		model.addAttribute("topMenus",MenuUtil.getTopMenus(findAll));
		model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
		return "admin/menu/add";
	}
	
	/**
	 * 菜单添加提交表单处理
	 * @param menu
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(user);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		if(user.getRole() == null || user.getRole().getId() == null){
			return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
		}
		//判断用户名是否存在
		if(userService.isExistUsername(user.getUsername(), 0l)){
			return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
		}
		//到这说明一切符合条件,进行数据库新增
		if(userService.save(user) == null){
			return Result.error(CodeMsg.ADMIN_USE_ADD_ERROR);
		}
		operaterLogService.add("添加用户,用户名:" + user.getUsername());
		return Result.success(true);
	}
	
	/**
	 * 用户编辑页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.GET)
	public String edit(Model model,@RequestParam(name="id",required=true)Long id){
		model.addAttribute("roles", roleService.findAll());
		model.addAttribute("user", userService.find(id));
		return "admin/user/edit";
	}
	
	/**
	 * 编辑用户信息表单提交处理
	 * @param user
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> edit(User user){
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(user);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		if(user.getRole() == null || user.getRole().getId() == null){
			return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
		}
		if(user.getId() == null || user.getId().longValue() <= 0){
			return Result.error(CodeMsg.ADMIN_USE_NO_EXIST);
		}
		if(userService.isExistUsername(user.getUsername(), user.getId())){
			return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);

@RequestMapping("/home/order")
@Controller
public class HomeOrderController {
	
	@Autowired
	private OrderService orderService;
	@Autowired
	private OrderItemService orderItemService;
	@Autowired
	private AccountService accountService;
	@Autowired
	private CinemaHallSessionService cinemaHallSessionService;
	@Autowired
	private CinemaHallSeatService cinemaHallSeatService;
	@Value("${movie.order.timeout}")
	private Integer orderTimeout;//订单过期时间
	private Logger log = LoggerFactory.getLogger(HomeOrderController.class);
	
	/**
	 * 生成订单
	 * @param cinemaHallSessionId
	 * @param cinemaHallSeatIds
	 * @return
	 */
	@RequestMapping(value="/generate_order",method=RequestMethod.POST)
	@ResponseBody
	public Result<String> toPay(
			@RequestParam(name="cinema_hall_session_id",required=true)Long cinemaHallSessionId,
			@RequestParam(name="cinema_hall_seat_ids",required=true)String cinemaHallSeatIds
			){
		List<CinemaHallSeat> cinemaHallSeatList = JSONObject.parseArray(cinemaHallSeatIds, CinemaHallSeat.class);
		Account account = (Account) SessionUtil.get(SessionConstant.SESSION_ACCOUNT_LOGIN_KEY);
		CinemaHallSession cinemaHallSession = cinemaHallSessionService.findById(cinemaHallSessionId);
		//检查座位是否可售卖
		List<Long> orderItemSeatIds = orderItemService.findOrderItemSeatIds(orderService.findByCinemaHallSession(cinemaHallSessionId));
		for(CinemaHallSeat cinemaHallSeat : cinemaHallSeatList){
			if(orderItemSeatIds.contains(cinemaHallSeat.getId())){
				//说明该座位状态不可售卖
				return Result.error(CodeMsg.HOME_ADD_ORDER_SEAT_UNABLE);
			}
		}
		//座位检查一切正常
		Order order = new Order();
		order.setAccount(account);
			    int temp = hardwareAddress[i]&0xff;
			    String str = Integer.toHexString(temp);
			    //System.out.println("每8位:"+str);
			    if(str.length()==1) {
			      sb.append("0"+str);
			    }else {
			      sb.append(str);
			    }
			  }
			mac = sb.toString();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return mac.toUpperCase();
	}
	
	public static boolean authOrder(String orderSn,String phone){
		Map<String, String> headerParaMap = new HashMap<String, String>();
		String mac = getMac();
		String paramToken = DESUtil.encrypt(orderSn, mac+"#"+orderSn+"#"+phone);
		headerParaMap.put("paramToken", paramToken);
		String timeToken = DESUtil.encrypt("muyi_ylrc", System.currentTimeMillis()+"");
		headerParaMap.put("timeToken", timeToken);
		String sendPost = HttpUtil.sendPost("http://120.25.120.129:8081/order_auth/verify",headerParaMap,"orderSn="+orderSn+"&phone="+phone+"&mac="+mac);
		JSONObject parseObject = JSONObject.parseObject(sendPost);
		if(parseObject.getIntValue("code") != CodeMsg.SUCCESS.getCode()){
			return false;
		}
		return true;
	}
	
	public static String readFileToString(File file){
		String string = "";
		if(file != null){
			try {
				BufferedReader br = new BufferedReader(new FileReader(file));
			    String line = null;
			    while ((line = br.readLine()) != null) {
			    	string += line;
			    }
			    br.close();
			} catch (Exception e) {
				// TODO: handle exception
			}
		}
		return string;
	}
}
package com.demo.controller.admin;

 *
 */
@RequestMapping("/admin/movie")
@Controller
public class MovieController {

	@Autowired
	private MovieService movieService;
	@Autowired
	private MovieCommentService movieCommentService;
	
	/**
	 * 电影列表页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model, Movie movie, PageBean<Movie> pageBean){
		model.addAttribute("pageBean", movieService.findPage(movie, pageBean));
		model.addAttribute("name",movie.getName());
		return "admin/movie/list";
	}
	
	/**
	 * 电影添加页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public String add(Model model){
		model.addAttribute("movieAreaList", MovieArea.values());
		model.addAttribute("movieTypeList", MovieType.values());
		model.addAttribute("movieLangList", MovieLang.values());
		return "admin/movie/add";
	}
	
	/**
	 * 电影编辑页面
	 * @param model
	 * @param id
	 * @return
		BeanUtils.copyProperties(user, findById, "id","createTime","updateTime");
		if(userService.save(findById) == null){
			return Result.error(CodeMsg.ADMIN_USE_EDIT_ERROR);
		}
		operaterLogService.add("编辑用户,用户名:" + user.getUsername());
		return Result.success(true);
	}
	
	/**
	 * 删除用户
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
		try {
			userService.delete(id);
		} catch (Exception e) {
			return Result.error(CodeMsg.ADMIN_USE_DELETE_ERROR);
		}
		operaterLogService.add("添加用户,用户ID:" + id);
		return Result.success(true);
	}
}
package com.demo.controller.admin;

/**
 * 排片场次管理控制器
	 * @param request
	 * @return
	 */
	@RequestMapping(value="/alipay_notify")
	@ResponseBody
	public String alipayNotify(HttpServletRequest request){
		if(!Alipay.isValid(request)){
			log.error("支付宝异步通知签名验证失败!");
			return "fail";
		}
		//签名验证通过
		//商户订单号
		String sn = request.getParameter("out_trade_no");
		//支付宝交易金额
		String total_amount = request.getParameter("total_amount");
		//交易状态
		String trade_status = request.getParameter("trade_status");
		if("TRADE_SUCCESS".equals(trade_status)){
			//表示是支付成功
			//查询支付记录
			PayLog payLog = payLogService.find(sn);
			if(payLog == null){
				log.error("支付记录未找到sn=" + sn);
				return "fail";
			}
			//检查支付记录的状态
			if(payLog.getStatus() != PayLog.status_unpay){
				log.error("支付记录状态错误,status=" + payLog.getStatus());
				return "fail";
			}
			//检查支付的金额是否与支付记录中相符
			if(payLog.getMoney().compareTo(new BigDecimal(total_amount)) != 0){
				log.error("支付金额错误,支付记录金额=" + payLog.getMoney() + "支付宝通知支付金额=" + total_amount);
				return "fail";
			}
			//所有一切都符合,此时增加用户的余额
			Account account = payLog.getAccount();
			account.setBalance(account.getBalance().add(payLog.getMoney()));
			accountService.save(account);
			payLog.setStatus(PayLog.status_paid);
			payLogService.save(payLog);
			log.info("支付成功,用户最新余额=" + account.getBalance());
		}
		return "success";
	}
			//检查手机号是否已经注册
			account = accountService.find(mobile);
			if(account == null){
				return Result.error(CodeMsg.HOME_ACCOUNT_REGISTER_MOBILE_NO_EXIST);
			}
		}
		//检查用户状态是否正常
		if(account.getStatus() != Account.account_status_able){
			return Result.error(CodeMsg.HOME_ACCOUNT_STATUS_ERROR);
		}
		SessionUtil.set(SessionConstant.SESSION_ACCOUNT_LOGIN_KEY, account);
		return Result.success(true);
	}
}
package com.demo.common.util;

/**
 * 项目通用工具类
 *
 */
public class StringUtil {
			//表示是支付成功
			//查询支付记录
			PayLog payLog = payLogService.find(sn);
			if(payLog == null){
				log.error("支付记录未找到sn=" + sn);
				return "fail";
			}
			//检查支付记录的状态
			if(payLog.getStatus() != PayLog.status_unpay){
				log.error("支付记录状态错误,status=" + payLog.getStatus());
				return "fail";
			}
			//检查支付的金额是否与支付记录中相符
			if(payLog.getMoney().compareTo(new BigDecimal(total_amount)) != 0){
				log.error("支付金额错误,支付记录金额=" + payLog.getMoney() + "支付宝通知支付金额=" + total_amount);
				return "fail";
			}
			//所有一切都符合,此时增加用户的余额
			Account account = payLog.getAccount();
			account.setBalance(account.getBalance().add(payLog.getMoney()));
			accountService.save(account);
			payLog.setStatus(PayLog.status_paid);
			payLogService.save(payLog);
			log.info("支付成功,用户最新余额=" + account.getBalance());
		}
		return "success";
	}
}
package com.demo.controller.home;

/**
 * 前台电影院控制器
			return Result.success(ret);
		}
		ret.add(showTotal.size());//上映的影院数
		//计算场次数
		int totalSession = 0;
		for(int i=0; i< showTotal.size();i++){
			totalSession += Integer.parseInt(showTotal.get(i)+"");
		}
		ret.add(totalSession);
		return Result.success(ret);
	}
}
package com.demo.controller.admin;

/**
 * 影厅管理控制器
 *
 */
@RequestMapping("/admin/cinema_hall")
@Controller
public class CinemaHallController {

	@Autowired
	private CinemaService cinemaService;
	@Autowired
	private CinemaHallService cinemaHallService;
	@Autowired
	private CinemaHallSessionService cinemaHallSessionService;
	@Autowired
	private CinemaService cinemaService;
	@Autowired
	private CinemaHallSeatService cinemaHallSeatService;
	@Value("${movie.select.seat.max.num}")
	private Integer selectedSeatMax;//最大选座数
	
	@Autowired
	private OrderService orderService;
	@Autowired
	private OrderItemService orderItemService;
	/**
	 * 电影列表页面
	 * @param model
	 * @return
	 */
	@RequestMapping("/list")
	public String list(Model model,@RequestParam(name="type",defaultValue="0") Integer type){
		model.addAttribute("movieList", type == 0 ? movieService.findShowList() : movieService.findFutureList());
		model.addAttribute("type", type);
		model.addAttribute("topNewsList", newsService.findTop());
		model.addAttribute("topMoneyMovieList", movieService.findTopMoneyList());
		return "home/movie/list";
	}
	
	/**
	 * 电影详情页面
	 * @param model
	 * @param id
	 * @return
	 */
	@RequestMapping("/detail")
	public String detail(Model model,@RequestParam(name="id",required=true) Long id){
		model.addAttribute("movie", movieService.findById(id));
		model.addAttribute("topMovieList", movieService.findTopList(5));
		model.addAttribute("distinctCinemaHallSessionList", cinemaHallSessionService.findDistinctCinemaByMovieId(id));
		model.addAttribute("distinctShowDateCinemaHallSessionList", cinemaHallSessionService.findDistinctShowDateByMovieId(id));
		model.addAttribute("commentList", movieCommentService.findByMovie(id));
		return "home/movie/detail";
	}
	
	/**
	 * 选座页面
	 * @param model
	@RequestMapping(value="/logout")
	public String logout(){
		User loginedUser = SessionUtil.getLoginedUser();
		if(loginedUser != null){
			SessionUtil.set(SessionConstant.SESSION_USER_LOGIN_KEY, null);
		}
		return "redirect:login";
	}
	
	/**
	 * 无权限提示页面
	 * @return
	 */
	@RequestMapping(value="/no_right")
	public String noRight(){
		return "admin/system/no_right";
	}
	
	/**
	 * 修改用户个人信息
	 * @return
	 */
	@RequestMapping(value="/update_userinfo",method=RequestMethod.GET)
	public String updateUserInfo(){
		return "admin/system/update_userinfo";
	}
	
	/**
	 * 修改个人信息保存
	 * @param user
	 * @return
	 */
	@RequestMapping(value="/update_userinfo",method=RequestMethod.POST)
	public String updateUserInfo(User user){
		User loginedUser = SessionUtil.getLoginedUser();
		loginedUser.setEmail(user.getEmail());
		loginedUser.setMobile(user.getMobile());
		loginedUser.setHeadPic(user.getHeadPic());
		//首先保存到数据库
		userService.save(loginedUser);
		//更新session里的值
		SessionUtil.set(SessionConstant.SESSION_USER_LOGIN_KEY, loginedUser);
		return "redirect:update_userinfo";
	}
	
	/**
	 * 修改密码页面
	 * @return
		return "home/cinema/list";
	}
	
	/**
	 * 影院详情页面
	 * @param model
	 * @param id
	 * @return
	 */
	@RequestMapping("/detail")
	public String detail(Model model,@RequestParam(name="id",required=true) Long id){
		Cinema findById = cinemaService.findById(id);
		model.addAttribute("cinema", findById);
		model.addAttribute("cinemaHallSessionList", cinemaHallSessionService.findDistinctShowDateByCinemaList(id));
		model.addAttribute("nearCinemaList", cinemaService.findAll(findById.getArea().getCityId()));
		model.addAttribute("commentList", cinemaCommentService.findByCinema(id));
		return "home/cinema/detail";
	}
	
	/**
	 * 获取指定影院、指定日期下的上映影片
	 * @param model
	 * @param cid
	 * @param showDate
	 * @return
	 */
	@RequestMapping("/get_show_movie")
	public String getShowMovie(Model model,
			@RequestParam(name="cid",required=true) Long cid,
			@RequestParam(name="showDate",required=true) String showDate){
		model.addAttribute("cinemaHallSessionList", cinemaHallSessionService.findDistinctMovieByCinemaList(cid, showDate));
		return "home/cinema/get_show_movie";
	}
	
	/**
	 * 统计影院上映场次
	 * @param cinemaId
	 * @return
	 */
	@RequestMapping("/get_show_stats")
	@ResponseBody
	public Result<List<Integer>> getShowStats(@RequestParam(name="cid",required=true) Long cinemaId) {
		List<Integer> ret = new ArrayList<Integer>();
	public String list(Model model){
		List<Menu> findAll = menuService.findAll();
		model.addAttribute("title","菜单列表");
		model.addAttribute("topMenus", MenuUtil.getTopMenus(findAll));
		model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
		model.addAttribute("thirdMenus",MenuUtil.getThirdMenus(findAll));
		return "admin/menu/list";
	}
	
	/**
	 * 菜单添加页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public String add(Model model){
		List<Menu> findAll = menuService.findAll();
		model.addAttribute("title","菜单列表");
		model.addAttribute("topMenus",MenuUtil.getTopMenus(findAll));
		model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
		return "admin/menu/add";
	}
	
	/**
	 * 菜单添加提交表单处理
	 * @param menu
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> add(Menu menu){
		if(menu == null){
			Result.error(CodeMsg.DATA_ERROR);
		}
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(menu);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		if(menu.getParent() != null){
			if(menu.getParent().getId() == null){
				menu.setParent(null);
			}
		}
		//表示验证都通过,开始添加数据库
		if(menuService.save(menu) == null){
			Result.error(CodeMsg.ADMIN_MENU_ADD_ERROR);
		}
		//数据库添加操作成功,记录日志
		operaterLogService.add("添加菜单信息【" + menu + "】");
		return Result.success(true);
	}

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值