基于javaweb+mysql的springboot体育用品商城(java+springboot+jsp+maven+mysql)

基于javaweb+mysql的springboot体育用品商城(java+springboot+jsp+maven+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

基于javaweb+mysql的SpringBoot体育用品商城(java+springboot+jsp+maven+mysql)

本项目为前后台管理系统,包括管理员与普通用户两种角色;

管理员角色包含以下功能: 管理员登录,用户管理,商品类型管理,商品管理,订单信息管理,用户留言管理,资讯管理等功能。

用户角色包含以下功能: 用户首页,用户登录,商品推荐,资讯信息,留言板,查看商品,提交订单,查看订单信息,个人资料管理等功能。

ps:推荐模块用了协同过滤推荐算法,下订单模块用的是百度地图api。本商城可以修改为任意商城不止是体育商城。

			ZixunExample zixunExample = new ZixunExample();
			Criteria criteria = zixunExample.createCriteria();
			if(zixun!=null&&zixun.getTitle()!=null&&!zixun.getTitle().equals("")) {
				criteria.andTitleLike(zixun.getTitle());
			}
		 
			
			//查询商品类型列表
			List<Zixun> zixuns = zixunMapper.selectByExample(zixunExample); 
			
			model.addAttribute("zixuns", zixuns);
//			model.addAttribute("zixun", zixun);
			paperUtil.setTotalCount(zixuns.size());
			
		} catch (Exception e) {
			setErrorTip("查询商品类型异常", "main.jsp", model);
			return "infoTip";
		}
		
 		return "zixunlist";
	}
 
	@RequestMapping(value="admin/addzixun.action")
	public String addzixun(Zixun zixun,PaperUtil paperUtil,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		zixun.setTime(new Date());
		zixunMapper.insert(zixun);
		try {
			if (zixun==null) {
				zixun = new Zixun();
			}
			
			//设置分页信息
			if (paperUtil==null) {
				paperUtil = new PaperUtil();
			}
			paperUtil.setPagination(zixun);
			//总的条数
			int[] sum={0};
			//查询商品类型列表
			List<Zixun> zixuns = zixunMapper.selectByExample(new ZixunExample()); 
			
			model.addAttribute("zixuns", zixuns);
//			model.addAttribute("zixun", zixun);
			paperUtil.setTotalCount(zixuns.size());
			
		} catch (Exception e) {
			setErrorTip("查询商品类型异常", "main.jsp", model);
			return "infoTip";
		}
		return "zixunlist";
			//新增留言
			indexManager.addSblog(paramsSblog);

		} catch (Exception e) {
			e.printStackTrace();
			jsonData.setErrorReason("新增留言失败!");
			return jsonData;
		}

		return jsonData;
	}

	/**
	 * @Title: saveAdmin
	 * @Description: 保存修改个人信息
	 * @return String
	 */
	@RequestMapping(value="page_saveUserFront.action",method=RequestMethod.POST)
	@ResponseBody
	public JSONData saveUserFront(User paramsUser,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		JSONData jsonData = new JSONData();
		try {
			//保存修改个人信息
			indexManager.updateUser(paramsUser);
			//更新session
			User admin = new User();
			admin.setUser_id(paramsUser.getUser_id());
			admin = indexManager.queryUser(admin);
			httpSession.setAttribute("userFront", admin);
		} catch (Exception e) {
			e.printStackTrace();
			jsonData.setErrorReason("后台服务器异常");
			return jsonData;
		}
		return jsonData;
	}

	/**
	 * @Title: saveUserFrontPass
	 * @Description: 保存修改个人密码
	 * @return String
	 */
	@RequestMapping(value="page_saveUserFrontPass.action",method=RequestMethod.POST)
	}

	/**
	 * @Title: listSblogs
	 * @Description: 留言信息
	 * @return String
	 */
	@RequestMapping(value="page_listSblogs.action")
	public String listSblogs(Sblog paramsSblog,PaperUtil paperUtil,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		try {
			//查询留言信息集合
			if (paramsSblog==null) {
				paramsSblog = new Sblog();
			}
			if (paperUtil==null) {
				paperUtil = new PaperUtil();
			}
			//设置分页信息
			paperUtil.setPagination(paramsSblog);
			int[] sum={0};
			List<Sblog> sblogs = indexManager.listSblogs(paramsSblog,sum); 
			model.addAttribute("sblogs", sblogs);
			paperUtil.setTotalCount(sum[0]);

		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}

		return "sblog";
	}

	/**
	 * @Title: addSblog
	 * @Description: 新增留言
	 * @return String
	 */
	@RequestMapping(value="page_addSblog.action")
	@ResponseBody
	public JSONData addSblog(Sblog paramsSblog,PaperUtil paperUtil,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		JSONData jsonData = new JSONData();
		try {
			//新增留言
			indexManager.addSblog(paramsSblog);
	 * @return List<Uview>
	 */
	public List<Uview> listUviews(Uview uview, int[] sum) {
		if (sum != null) {
			sum[0] = uviewDao.listUviewsCount(uview);
		}
		List<Uview> uviews = uviewDao.listUviews(uview);

		return uviews;
	}

	/**
	 * @Title: queryUview
	 * @Description: 浏览记录查询
	 * @param uview
	 * @return Uview
	 */
	public Uview queryUview(Uview uview) {
		Uview _uview = uviewDao.getUview(uview);
		return _uview;
	}

	/**
	 * @Title: addUview
	 * @Description: 添加浏览记录
	 * @param uview
	 * @return void
	 */
	public void addUview(Uview uview) {
		uviewDao.addUview(uview);
	}
	
	/**
	 * @Title: listGoodssSimilarity
	 * @Description: 根据协同过滤算法得出商品推荐
	 * @param goods
	 * @return List<Goods>
	 */
	public List<Goods>  listGoodssSimilarity(HttpSession session){
		List<Goods> recomLists = new ArrayList<>();
		
		User userFront = (User)session.getAttribute("userFront");//当前用户
		int uid = userFront.getUser_id();//当前用户ID
		
		List<Goods> likeLists;  //其他用户喜欢的商品列表
		List<User> users = userDao.listUsers(new User()); //所有用户列表
			//总的条数
			int[] sum={0};
			//查询商品类型列表
			List<Zixun> zixuns = zixunMapper.selectByExample(new ZixunExample()); 
			
			model.addAttribute("zixuns", zixuns);
//			model.addAttribute("zixun", zixun);
			paperUtil.setTotalCount(zixuns.size());
			
		} catch (Exception e) {
			setErrorTip("查询商品类型异常", "main.jsp", model);
			return "infoTip";
		}
		return "zixunlist";
	}
	@RequestMapping(value="admin/updatezixun.action")
	public String updatezixun(Zixun zixun,PaperUtil paperUtil,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		zixun.setTime(new Date());
		ZixunExample zixunExample = new ZixunExample();
		Criteria criteria = zixunExample.createCriteria();
		criteria.andIdEqualTo(zixun.getId());
		zixunMapper.updateByExampleSelective(zixun, zixunExample);
		try {
			if (zixun==null) {
				zixun = new Zixun();
			}
			
			//设置分页信息
			if (paperUtil==null) {
				paperUtil = new PaperUtil();
			}
			paperUtil.setPagination(zixun);
			//总的条数
			int[] sum={0};
			//查询商品类型列表
			List<Zixun> zixuns = zixunMapper.selectByExample(new ZixunExample()); 
			
			model.addAttribute("zixuns", zixuns);
//			model.addAttribute("zixun", zixun);
			paperUtil.setTotalCount(zixuns.size());
			
		} catch (Exception e) {
			setErrorTip("查询商品类型异常", "main.jsp", model);
			return "infoTip";
		}
		return "zixunlist";
	}
 	/**
				httpSession.setAttribute("userFront", userFront);
			}
		} catch (Exception e) {
			e.printStackTrace();
			jsonData.setErrorReason("后台服务器异常");
			return jsonData;
		}
		return jsonData;
	}

	/**
	 * @Title: listMyOrderss
	 * @Description: 查询我的商品订单
	 * @return String
	 */
	@RequestMapping(value="page_listMyOrderss.action")
	public String listMyOrderss(Orders paramsOrders,PaperUtil paperUtil,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		try {
			if (paramsOrders==null) {
				paramsOrders = new Orders();
			}
			//获取用户,用户只能查询自己的订单
			User userFront = (User)httpSession.getAttribute("userFront");
			paramsOrders.setUser_id(userFront.getUser_id());
			//设置分页信息
			paperUtil.setPagination(paramsOrders);
			//总的条数
			int[] sum={0};
			//查询商品预约列表
			List<Orders> orderss = indexManager.listOrderss(paramsOrders,sum); 

			model.addAttribute("orderss", orderss);
			paperUtil.setTotalCount(sum[0]);

		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}

		return "ordersShow";
	}

	/**
	 * @Title: listMyOrdersDetails
	 * @Title: addGoodsTypeShow
	 * @Description: 显示添加商品类型页面
	 * @return String
	 */
	@RequestMapping(value="admin/Admin_addGoodsTypeShow.action",method=RequestMethod.GET)
	public String addGoodsTypeShow(){
		return "goodsTypeEdit";
	}
	
	/**
	 * @Title: addGoodsType
	 * @Description: 添加商品类型
	 * @return String
	 */
	@RequestMapping(value="admin/Admin_addGoodsType.action",method=RequestMethod.POST)
	public String addGoodsType(GoodsType paramsGoodsType,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		try {
			//检查商品类型是否存在
			GoodsType goodsType = new GoodsType();
			goodsType.setGoods_type_name(paramsGoodsType.getGoods_type_name());
			goodsType = adminManager.queryGoodsType(goodsType);
			if (goodsType!=null) {
				String tip="失败,该商品类型已经存在!";
				model.addAttribute("tip", tip);
				model.addAttribute("goodsType", paramsGoodsType);
				
				return "goodsTypeEdit";
			}
			
			 //添加商品类型
			adminManager.addGoodsType(paramsGoodsType);
			
			setSuccessTip("添加成功", "Admin_listGoodsTypes.action",model);
		} catch (Exception e) {
			setErrorTip("添加商品类型异常", "Admin_listGoodsTypes.action", model);
		}
		
		return "infoTip";
	}
	
	 
 
	@RequestMapping(value="admin/addzixun.action")
	public String addzixun(Zixun zixun,PaperUtil paperUtil,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		zixun.setTime(new Date());
		zixunMapper.insert(zixun);
		try {
			if (zixun==null) {
				zixun = new Zixun();
			}
			
			//设置分页信息
			if (paperUtil==null) {
				paperUtil = new PaperUtil();
			}
			paperUtil.setPagination(zixun);
			//总的条数
			int[] sum={0};
			//查询商品类型列表
			List<Zixun> zixuns = zixunMapper.selectByExample(new ZixunExample()); 
			
			model.addAttribute("zixuns", zixuns);
//			model.addAttribute("zixun", zixun);
			paperUtil.setTotalCount(zixuns.size());
			
		} catch (Exception e) {
			setErrorTip("查询商品类型异常", "main.jsp", model);
			return "infoTip";
		}
		return "zixunlist";
	}
	@RequestMapping(value="admin/updatezixun.action")
	public String updatezixun(Zixun zixun,PaperUtil paperUtil,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		zixun.setTime(new Date());
		ZixunExample zixunExample = new ZixunExample();
		Criteria criteria = zixunExample.createCriteria();
		criteria.andIdEqualTo(zixun.getId());
		zixunMapper.updateByExampleSelective(zixun, zixunExample);
		try {
	 */
	@RequestMapping(value="page_queryGoods.action",method=RequestMethod.GET)
	public String queryGoods(Goods paramsGoods,Evaluate paramsEvaluate,PaperUtil paperUtil,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		try {
			//得到商品
			Goods goods = indexManager.queryGoods(paramsGoods);
			model.addAttribute("goods", goods);

			//查询评价集合
			paperUtil.setPagination(paramsEvaluate);
			int[] sum={0};
			List<Evaluate> evaluates = indexManager.listEvaluates(paramsEvaluate,sum); 
			model.addAttribute("evaluates", evaluates);
			paperUtil.setTotalCount(sum[0]);

			//添加浏览记录
			User userFront = (User)httpSession.getAttribute("userFront");
			if (userFront!=null) {
				Uview uview = new Uview();
				uview.setUser_id(userFront.getUser_id());
				uview.setGoods_id(goods.getGoods_id());
				uview = indexManager.queryUview(uview);
				if (uview==null) {
					uview = new Uview();
					uview.setUser_id(userFront.getUser_id());
					uview.setGoods_id(goods.getGoods_id());
					indexManager.addUview(uview);
				}
			}

		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}

		return "goodsDetail";
	}

	/**
	 * @Title: listCard
	 * @Description: 查询购物车
	 * @return String
			//查询注册用户列表
			List<User> users = adminManager.listUsers(paramsUser,sum); 
			model.addAttribute("users", users);
			model.addAttribute("paramsUser", paramsUser);
			paperUtil.setTotalCount(sum[0]);

		} catch (Exception e) {
			setErrorTip("查询注册用户异常", "main.jsp", model);
			return "infoTip";
		}
		
		return "userShow";
	}
	
	/**
	 * @Title: addUserShow
	 * @Description: 显示添加注册用户页面
	 * @return String
	 */
	@RequestMapping(value="admin/Admin_addUserShow.action",method=RequestMethod.GET)
	public String addUserShow(ModelMap model){
		return "userEdit";
	}
	
	/**
	 * @Title: addUser
	 * @Description: 添加注册用户
	 * @return String
	 */
	@RequestMapping(value="admin/Admin_addUser.action",method=RequestMethod.POST)
	public String addUser(User paramsUser,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		try {
			//检查注册用户是否存在
			User user = new User();
			user.setUser_name(paramsUser.getUser_name());
			user = adminManager.queryUser(user);
			if (user!=null) {
				model.addAttribute("tip","失败,该用户名已经存在!");
				model.addAttribute("user", paramsUser);
				
				return "userEdit";
			}
			 //添加注册用户
			paramsUser.setUser_flag(1);
			paramsUser.setReg_date(DateUtil.getCurDateTime());
			adminManager.addUser(paramsUser);
			
			setSuccessTip("添加成功", "Admin_listUsers.action", model);
		} catch (Exception e) {
			setErrorTip("添加注册用户异常", "Admin_listUsers.action", model);
		}
		
	 * @Description: 查询购物车
	 * @return String
	 */
	@RequestMapping(value="page_listCard.action")
	public String listCard(ModelMap model,HttpSession httpSession){
		try {
			//查询购物车
			List<OrdersDetail> ordersDetails = new ArrayList<OrdersDetail>();
			User user = (User)httpSession.getAttribute("userFront");
			if(user == null) {
				model.addAttribute("tip","登录超时请重新登录!");
				return "login";
			}
			GouWuChe gouwuche = new GouWuChe();
			gouwuche.setUser_id(user.getUser_id());
			List<GouWuChe> gouWuChes = gouWuCheDao.listGouWuChes(gouwuche);
			if(gouWuChes != null) {
				for(GouWuChe tempChe : gouWuChes) {
					OrdersDetail ordersDetail = new OrdersDetail();
					Goods goods = new Goods();
					goods.setGoods_id(tempChe.getGoods_id());
					Goods dbGoods = goodsDao.getGoods(goods);
					ordersDetail.setGoods_id(dbGoods.getGoods_id());
					ordersDetail.setGoods_name(dbGoods.getGoods_name());
					ordersDetail.setGoods_price(dbGoods.getGoods_price());
					ordersDetail.setGoods_discount(dbGoods.getGoods_discount());
					ordersDetail.setGoods_count(tempChe.getCount());
					ordersDetail.setGoods_money(dbGoods.getGoods_price()*tempChe.getCount());
					ordersDetails.add(ordersDetail);
				}
			}
			httpSession.removeAttribute("ordersDetails");
			httpSession.setAttribute("ordersDetails", ordersDetails);
			model.addAttribute("ordersDetails", ordersDetails);

		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}

		return "card";
	}

	/**
	 * @Title: addCard
	 * @Description: 添加到购物车
	 */
	@RequestMapping(value="admin/Admin_listGoodsTypes.action")
	public String listGoodsTypes(GoodsType paramsGoodsType,PaperUtil paperUtil,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		try {
			if (paramsGoodsType==null) {
				paramsGoodsType = new GoodsType();
			}
			
			//设置分页信息
			if (paperUtil==null) {
				paperUtil = new PaperUtil();
			}
			paperUtil.setPagination(paramsGoodsType);
			//总的条数
			int[] sum={0};
			//查询商品类型列表
			List<GoodsType> goodsTypes = adminManager.listGoodsTypes(paramsGoodsType,sum); 
			
			model.addAttribute("goodsTypes", goodsTypes);
			model.addAttribute("paramsGoodsType", paramsGoodsType);
			paperUtil.setTotalCount(sum[0]);
			
		} catch (Exception e) {
			setErrorTip("查询商品类型异常", "main.jsp", model);
			return "infoTip";
		}
		
		return "goodsTypeShow";
	}
	
	/**
	 * @Title: addGoodsTypeShow
	 * @Description: 显示添加商品类型页面
	 * @return String
	 */
	@RequestMapping(value="admin/Admin_addGoodsTypeShow.action",method=RequestMethod.GET)
	public String addGoodsTypeShow(){
		return "goodsTypeEdit";
	}
	
	/**
	 * @Title: addGoodsType
			if (paramsOrdersDetail==null) {
				paramsOrdersDetail = new OrdersDetail();
			}
			//设置分页信息
			paperUtil.setPagination(paramsOrdersDetail);
			//总的条数
			int[] sum={0};
			//查询商品订单明细
			List<OrdersDetail> ordersDetails = adminManager.listOrdersDetails(paramsOrdersDetail,sum); 
			
			model.addAttribute("ordersDetails", ordersDetails);
			paperUtil.setTotalCount(sum[0]);
			
			model.addAttribute("orders_no", paramsOrdersDetail.getOrders_no());
			if (ordersDetails!=null && ordersDetails.size()>0) {
				model.addAttribute("orders_money", ordersDetails.get(0).getOrders_money());
			}
			
			
		} catch (Exception e) {
			setErrorTip("查询商品订单明细异常", "main.jsp", model);
			return "infoTip";
		}
		
		return "ordersDetailShow";
	}
	
	/**
	 * @Title: validateAdmin
	 * @Description: admin登录验证
	 * @return boolean
	 */
	private boolean validateAdmin(HttpSession httpSession){
		Manager admin = (Manager)httpSession.getAttribute("admin");
		if (admin!=null) {
			return true;
		}else {
			return false;
		}
	}
	
	private void setErrorTip(String tip,String url,ModelMap model){
		model.addAttribute("tipType", "error");
		model.addAttribute("tip", tip);
		model.addAttribute("url1", url);
		model.addAttribute("value1", "确 定");
	}
	
	private void setSuccessTip(String tip,String url,ModelMap model){
		model.addAttribute("tipType", "success");
		model.addAttribute("tip", tip);
		model.addAttribute("url1", url);
		model.addAttribute("value1", "确 定");
		JSONData jsonData = new JSONData();
		try {
			//用户查询
			User user = (User)httpSession.getAttribute("userFront");
			if (user!=null) {
				//退出登录
				httpSession.removeAttribute("userFront");
				httpSession.invalidate();
			}
			
		} catch (Exception e) {
			jsonData.setErrorReason("退出异常,请稍后重试");
			return jsonData;
		}
		
		return jsonData;
	}
	
	/**
	 * @Title: RegSystem
	 * @Description: 用户注册
	 * @return String
	 */
	@RequestMapping(value="LoginRegSystem.action",method=RequestMethod.POST)
	@ResponseBody
	public JSONData RegSystem(User params,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		JSONData jsonData = new JSONData();
		try {
			//验证码验证
//			String random = (String)httpSession.getAttribute("random");
//			if (!random.equals(params.getRandom())) {
//				jsonData.setErrorReason("验证码错误");
//				return jsonData;
//			}
			
			//查询用户名是否被占用
			User user = new User();
			user.setUser_name(params.getUser_name());
			User user_temp = loginIndexManager.getUser(user);
			if (user_temp!=null) {
				jsonData.setErrorReason("注册失败,用户名已被注册:"+params.getUser_name());
				return jsonData;
			}
			
			//添加用户入库
			params.setUser_flag(1);
			params.setReg_date(DateUtil.getCurDateTime());
			loginIndexManager.addUser(params);
	/**
	 * @Title: listSblogReplys
	 * @Description: 查询回复集合
	 * @param user
	 * @return List<User>
	 */
	public List<SblogReply> listSblogReplys(SblogReply user, int[] sum) {
		if (sum != null) {
			sum[0] = sblogReplyDao.listSblogReplysCount(user);
		}
		List<SblogReply> sblogReplys = sblogReplyDao.listSblogReplys(user);
		return sblogReplys;
	}
	
	/**
	 * @Title: addSblogReply
	 * @Description: 添加回复
	 * @param sblogReply
	 * @return void
	 */
	public void addSblogReply(SblogReply sblogReply) {
		//添加回复
		if (!StringUtil.isEmptyString(sblogReply.getReply_content())) {
			sblogReply.setReply_content(Transcode.htmlEncode(sblogReply.getReply_content()));
		}
		sblogReply.setReply_date(DateUtil.getCurDateTime());
		
		sblogReplyDao.addSblogReply(sblogReply);
	}
	
	/**
	 * @Title: listUviews
	 * @Description: 浏览记录查询
	 * @param uview
	 * @return List<Uview>
	 */
	public List<Uview> listUviews(Uview uview, int[] sum) {
		if (sum != null) {
			sum[0] = uviewDao.listUviewsCount(uview);
		}
		List<Uview> uviews = uviewDao.listUviews(uview);
			paperUtil.setTotalCount(goods.size());
			//查询商品类型
			GoodsType goodsType = new GoodsType();
			goodsType.setStart(-1);
			List<GoodsType> goodsTypes = indexManager.listGoodsTypes(goodsType, null);
			if (goodsTypes==null) {
				goodsTypes = new ArrayList<GoodsType>();
			}
			model.addAttribute("goodsTypes", goodsTypes);

		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}

		return "goodsHobby";
	}

	double getSimilarWithUserByGouWuChe(int me,int otherUserId) {
		GouWuChe gouwuche = new GouWuChe();
		gouwuche.setUser_id(otherUserId);
		List<Integer> mygoods_ids = new ArrayList<Integer>();
		List<Integer> mygoods_ids_clone = new ArrayList<Integer>();
		List<Integer> othergoods_ids = new ArrayList<Integer>();
		List<Integer> othergoods_ids_clone = new ArrayList<Integer>();
		List<GouWuChe> otherUserGouWuChes = (List<GouWuChe>) gouWuCheDao.listGouWuChes(gouwuche);
		for (GouWuChe gChe:otherUserGouWuChes) {
			othergoods_ids.add(gChe.getGoods_id());
			othergoods_ids_clone.add(gChe.getGoods_id());
		}
		gouwuche = new GouWuChe();
		gouwuche.setUser_id(me);
		List<GouWuChe> mygoodsGouWuChes = (List<GouWuChe>) gouWuCheDao.listGouWuChes(gouwuche);
		for (GouWuChe gChe:mygoodsGouWuChes) {
			mygoods_ids.add(gChe.getGoods_id());
		}
		mygoods_ids_clone.retainAll(othergoods_ids);//mygoods_ids变为交集
		int a = mygoods_ids_clone.size();
		int b = 0;
		othergoods_ids.removeAll(mygoods_ids);
		othergoods_ids.addAll(mygoods_ids);
		if(othergoods_ids.size() == 0) {
			b = 1;
		}else {
			b = othergoods_ids.size();
		}
		return a/b*1;
	}

	double getSimilarWithUserByDingdan(int me,int otherUserId) {
		DingDan dingdan = new DingDan();
			List<GouWuChe> gouWuChes = gouWuCheDao.listGouWuChes(gouwuche);
			if(gouWuChes != null) {
				for(GouWuChe tempChe : gouWuChes) {
					OrdersDetail ordersDetail = new OrdersDetail();
					Goods goods = new Goods();
					goods.setGoods_id(tempChe.getGoods_id());
					Goods dbGoods = goodsDao.getGoods(goods);
					ordersDetail.setGoods_id(dbGoods.getGoods_id());
					ordersDetail.setGoods_name(dbGoods.getGoods_name());
					ordersDetail.setGoods_price(dbGoods.getGoods_price());
					ordersDetail.setGoods_discount(dbGoods.getGoods_discount());
					ordersDetail.setGoods_count(tempChe.getCount());
					ordersDetail.setGoods_money(dbGoods.getGoods_price()*tempChe.getCount());
					ordersDetails.add(ordersDetail);
				}
			}
			httpSession.removeAttribute("ordersDetails");
			httpSession.setAttribute("ordersDetails", ordersDetails);
			model.addAttribute("ordersDetails", ordersDetails);

		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}

		return "card";
	}

	/**
	 * @Title: addCard
	 * @Description: 添加到购物车
	 * @return String
	 */
	@RequestMapping(value="page_addCard.action")
	public String addCard(OrdersDetail paramsOrdersDetail,PaperUtil paperUtil,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession){
		try {
			//添加到购物车
			indexManager.addCard(paramsOrdersDetail, httpSession);
			//查询购物车
			List<OrdersDetail> ordersDetails = indexManager.listCard(httpSession);
			model.addAttribute("ordersDetails", ordersDetails);
	@Autowired
	IGoodsDao goodsDao;
	@Autowired
	ZixunMapper zixunMapper;
	public IndexManager getIndexManager() {
		return indexManager;
	}
	public void setIndexManager(IndexManager indexManager) {
		this.indexManager = indexManager;
	}

	String tip;

	/**
	 * @Title: index
	 * @Description: 首页
	 * @return String
	 * @throws Exception 
	 */
	@RequestMapping(value= { " ", "", "/" },method=RequestMethod.GET)
	public void admin(Manager paramsManager,
			ModelMap model,HttpServletRequest request,HttpServletResponse response,HttpSession httpSession) throws Exception{
		response.sendRedirect(request.getContextPath() + "index.jsp");
	}

	/**
	 * @Title: index
	 * @Description: 首页
	 * @return String
	 */
	@RequestMapping(value="page_index.action",method=RequestMethod.GET)
	public String index(ModelMap model){
		//查询热销商品信息
		Goods goods = new Goods();
		goods.setStart(0);
		goods.setLimit(8);
		List<Goods> goodss = indexManager.listGoodssTop(goods);
		model.addAttribute("goodss", goodss);

		//查询最新上架商品
		List<Goods> goodss2 = indexManager.listGoodss(goods, null);
		model.addAttribute("goodss2", goodss2);

		return "default"; 
	}

	/**
	 * @Title: listGoodss
	 * @Description: 查询商品
	 * @return String

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值