基于javaweb+mysql的ssm鲜花商城系统(java+ssm+jsp+jquery+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM鲜花商城系统(java+ssm+jsp+jquery+mysql)
项目介绍
本项目分为前后台,前台为普通用户角色,后台为管理员角色;
管理员角色包含以下功能:
会员信息管理,售后管理,库存管理,查看营业额统计,查看销售量,查询顾客活跃度,留言管理,管理关于我们,管理员登录,管理滚动图片,类别管理,订单管理,资讯管理,鲜花管理等功能。
用户角色包含以下功能:
修改个人资料,发表留言,提交订单,提交评论,查看售后申请,查看商品详情,查看我的收藏,查看我的订单,查看我的购物车,查看留言板,查看鲜花分类,用户登录,确认支付等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目;
6.数据库:MySql 5.7、8.0等版本均可;
技术栈
-
后端:Spring+springmvc+mybatis
-
前端:JSP+css+javascript+jQuery
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat
-
将项目中db.properties配置文件中的数据库配置改为自己的配置;
-
运行项目,在浏览器中输入http://localhost:8080/ssm_zxxianhuashop/ 登录;
用户账号/密码: user/123456
管理员账号/密码:admin/admin
@RequestMapping("receiveOrder")
@ResponseBody
public String receiveOrder(String orderId){
Integer rs = orderService.receiveOrder(orderId);
if(rs>0){
return "success";
}else{
return "fail";
@RequestMapping("deleteOrder")
@ResponseBody
public String deleteOrder(String orderId){
Integer rs = orderService.deleteOrder(orderId);
} //调用SDK验证签名
//——请在这里编写您的程序(以下代码仅作参考)——
/* 实际验证过程建议商户务必添加以下校验:
1、需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号,
2、判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额),
3、校验通知中的seller_id(或者seller_email) 是否为out_trade_no这笔单据的对应的操作方(有的时候,一个商户可能有多个seller_id/seller_email)
4、验证app_id是否为该商户本身。
*/
PrintWriter out=null;
try {
out = response.getWriter();
} catch (IOException e) {
e.printStackTrace();
@RequestMapping("preOrder")
public String preOrder(Integer[] goodslist,Model model,HttpServletRequest request){
List<Cart> cartList=new ArrayList<Cart>();
for (Integer i : goodslist) {
Cart cart = cartService.findCartById(i);
cartList.add(cart);
model.addAttribute("cartList", cartList);
HttpSession session = request.getSession();
Users user = (Users) session.getAttribute("user");
List<Address> addrList = addressService.findAddressByUserId(user.getUserId());
model.addAttribute("addrList", addrList);
try {
out_trade_no = new String(orderId.getBytes("ISO-8859-1"),"UTF-8");
total_amount = new String((order.getOrderPrice()+"").getBytes("ISO-8859-1"),"UTF-8");
subject = new String("我的商城");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
//商品描述,可空
List<OrderDetail> detailList = order.getDetailList();
String body = null;
for (OrderDetail o : detailList) {
body=body+o.getDetailGoods().getGoodsName()+",";
body=body.substring(0, body.length()-1)+"等商品";
alipayRequest.setBizContent("{\"out_trade_no\":\""+ out_trade_no +"\","
public String addCartNum(Integer cartId){
Cart cart = cartService.findCartById(cartId);
cart.setCartNum(cart.getCartNum()+1);
Integer rs = cartService.updateCart(cart);
if(rs>0){
return "success";
}else{
return "fail";
@RequestMapping("preOrder")
public String preOrder(Integer[] goodslist,Model model,HttpServletRequest request){
List<Cart> cartList=new ArrayList<Cart>();
totalPrice+=cart.getCartNum()*cart.getCartGoods().getGoodsPrice();
cartList.add(cart);
OrderDetail detail=new OrderDetail(cart.getCartGoods(), cart.getCartGoods().getGoodsPrice()*cart.getCartNum(), cart.getCartNum());
detailList.add(detail);
HttpSession session = request.getSession();
Users user=(Users) session.getAttribute("user");
Date orderDate=new Date();
Address address = addressService.findAddresById(addr);
String a=address.getAddrProvince()+address.getAddrCity()+address.getAddrArea()+address.getAddrDetail();
Order order=new Order(user, orderDate, totalPrice, 1, address.getAddrNickname(), address.getAddrPhone(), a);
order.setDetailList(detailList);
Order takeOrder = orderService.takeOrder(order);
private IOrderService orderService;
@Autowired
private IAddressService addressService;
@Autowired
private IGuessService guessService;
@RequestMapping("takeOrder")
public String takeOrder(Integer[] goodslist,Integer addr,Model model,HttpServletRequest request){
List<Cart> cartList=new ArrayList<Cart>();
List<OrderDetail> detailList=new ArrayList<OrderDetail>();
Double totalPrice=0D;
for (Integer i : goodslist) {
Cart cart = cartService.findCartById(i);
if(trade_status.equals("TRADE_FINISHED")||trade_status.equals("TRADE_SUCCESS")){
//判断该笔订单是否在商户网站中已经做过处理
//如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序
//如果有做过处理,不执行商户的业务程序
Integer rs = orderService.payForOrder(out_trade_no);
if(rs>0){
System.out.println("异步通知支付成功");
//注意:
//付款完成后,支付宝系统发送该交易状态通知
out.println("success");
}else {//验证失败
@Autowired
private IGuessService guessService;
@Autowired
private IEvaluateService evaluateService;
@RequestMapping("findAll")
public String findAllGoods(Model model){
List<Goods> list = goodsService.findAll();
model.addAttribute("goodsList", list);
return "list";
@RequestMapping("/findGoodsDiscounts")
@ResponseBody
public JSONObject findGoodsDiscounts(){
Order out_trade_no = orderService.findOrderById(orderId);
Integer rs = orderService.payForOrder(orderId);
if(rs>0){
System.out.println("同步通知支付成功");
JSONObject obj=new JSONObject();
obj.put("result", "paysuccess");
return obj;
/**
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);
Cart c=new Cart(goods, num, goods.getGoodsPrice(), user);
cartService.addGoodsToCart(c);
return "success";
@RequestMapping("findCartByUser")
@ResponseBody
public List<Cart> findCartByUser(HttpServletRequest request){
HttpSession session = request.getSession();
Users user=(Users) session.getAttribute("user");
List<Cart> list = cartService.findCartByUserId(user.getUserId());
return list;
public class CartController {
@Autowired
private ICartService cartService;
@Autowired
private IGoodsService goodsService;
@Autowired
private IAddressService addressService;
@RequestMapping("addCart")
@ResponseBody
public String addToCart(Integer goodsId,Integer num,HttpServletRequest request){
HttpSession session = request.getSession();
PrintWriter out=null;
try {
out = response.getWriter();
} catch (IOException e) {
e.printStackTrace();
if(signVerified) {//验证成功
//商户订单号
String out_trade_no="";
//交易状态
String trade_status="";
try {
out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"),"UTF-8");
//支付宝交易号
private IGoodsService goodsService;
@Autowired
private IOrderService orderService;
@Autowired
private IAddressService addressService;
@Autowired
private IGuessService guessService;
@RequestMapping("takeOrder")
public String takeOrder(Integer[] goodslist,Integer addr,Model model,HttpServletRequest request){
List<Cart> cartList=new ArrayList<Cart>();
List<OrderDetail> detailList=new ArrayList<OrderDetail>();
obj.put("count", info.getTotal());
obj.put("data", info.getList());
return obj;
@RequestMapping("findGoodsByType")
@ResponseBody
public List<Goods> findGoodsByType(Integer typeId){
List<Goods> list = goodsService.findGoodsByType(typeId);
return list;
@RequestMapping("detail")
public String findGoodsDetail(Integer goodsId,Model model,HttpServletRequest request){
Goods goods = goodsService.findById(goodsId);
model.addAttribute("goods",goods);
model.addAttribute("evaList", goods.getEvaList());
public class GoodsController {
@Autowired
private IGoodsService goodsService;
@Autowired
private IGuessService guessService;
@Autowired
private IEvaluateService evaluateService;
@RequestMapping("findAll")
public String findAllGoods(Model model){
List<Goods> list = goodsService.findAll();
model.addAttribute("goodsList", list);
return "list";
JSONObject obj=new JSONObject();
obj.put("msg", "");
obj.put("code", 0);
obj.put("count", info.getTotal());
obj.put("data", info.getList());
return obj;
@RequestMapping("findGoodsByType")
@ResponseBody
public List<Goods> findGoodsByType(Integer typeId){
List<Goods> list = goodsService.findGoodsByType(typeId);
return list;
@RequestMapping("detail")