酒水推荐商城|基于Springboot实现酒水商城系统

简介: 酒水推荐商城|基于Springboot实现酒水商城系统

项目编号:BS-SC-036

一,项目简介


系统整体介绍:

本系统主要基于Springboot框架开发实现,实现了一个以茶叶为主题的商城系统。在本商城系统中,可以实现在线购买酒水,在线支付,管理个人订单,管理个人收货地址,确认收货等功能。用户浏览商城的茶叶产品后可以将茶叶商品添加到购物车中,然后下单支付购买。用户登陆后可以在个人中心中管理自己的购物车信息、订单信息、收货地址信息等。同样在商城前端页面中提供了全文搜索功能,用户可以根据酒水的相关功效或禁忌来查询符合自己要的酒水商品。


系统同样提供了强大的后台管理系统,在后台管理模块中可以实现能前台注册用户的管理操作,可以管理所有用户的订单信息,根据订单支付情况进行发货等操作。同样可以管理产品的分类,可以管理商品的信息,以图文的形式来添加商品信息。为了更好了了解商品的销售情况,在后台使用echart实现了商品销售的图形报表和订单的统计报表功能。


     系统使用了SpringSecurity框架来管理系统的用户登陆和权限认证操作,以保证系统的安全性。本系统功能完整,页面简洁大方,运行无误,适合做毕业设计使用。


     相似性推荐:根据用户的浏览商品的相似性做协同过滤运算,从而给用户进行商品的推荐。


     浏览记录查询:用户的浏览和搜索记录后台会进行记录,在用户进行搜索时会根据搜索关键词的总量进行排行,从而实现推荐的效果

image.png

image.png

二,环境介绍


语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

后台开发技术:springboot+springmvc+mybatis+ Springsecurity

前台开发技术:jsp+jquery+ajax+bootstrap

三,系统展示


系统首页

5a16beac10d341e38d5dffd564a51170.png

分类展示

image.png

商品详情

image.png

全文检索:记录用户检索历史记录并可以根据历史记录来进行快速搜索

image.png

根据品牌进行搜索

image.png

相似性推荐:根据用户的浏览商品的相似性做协同过滤运算,从而给用户进行商品的推荐

image.png

用户注册

image.png

用户登陆

image.png

登陆后可以进行商品购买

image.png

下单后可个人中心可以查看我的订单,并可以取消订单

image.png

个人中心管理个人收货地址

image.png

后台管理员登陆

image.png

用户管理

image.png

轮播图管理

image.png

商品分类动态维护

image.png

商品品牌管理

image.png

商品管理

image.png

订单管理

image.png

图形统计报表

image.png

image.png

四,核心代码展示


package com.yw.eshop.controller.front;
import com.yw.eshop.domain.Carousel;
import com.yw.eshop.domain.Product;
import com.yw.eshop.domain.ProductType;
import com.yw.eshop.domain.SearchHistory;
import com.yw.eshop.service.CarouselService;
import com.yw.eshop.service.ProductService;
import com.yw.eshop.service.ProductTypeService;
import com.yw.eshop.service.SearchHistoryService;
import com.yw.eshop.service.CarouselService;
import com.yw.eshop.service.ProductService;
import com.yw.eshop.service.ProductTypeService;
import com.yw.eshop.service.SearchHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
/**
 * 前端首页控制接口
 */
@Controller
@RequestMapping("/front")
public class FrontIndexController {
    @Autowired//轮播图
    private CarouselService carouselService ;
    @Autowired//商品类型
    private ProductTypeService productTypeService ;
    @Autowired//商品
    private ProductService productService ;
    @Autowired
    private SearchHistoryService searchHistoryService;
    @RequestMapping("/index")
    public String index(Model model){
        //轮播图
        List<Carousel> carousels = carouselService.queryCarouselAll();
        model.addAttribute("allcarouselFigures",carousels);
        //分类
        List<ProductType> productTypes = productTypeService.queryProductTypeAll();
        model.addAttribute("allProductTypes",productTypes);
        //新品
        List<Product> newProducts = productService.queryNewProduct(6);
        model.addAttribute("newProducts", newProducts);
        //查询热搜词
        List<SearchHistory> searchHistorys = searchHistoryService.querySearchHistoryPages(10);
        model.addAttribute("searchHistorys",searchHistorys);
        //排行榜
        List<Product> rankings = productService.queryProductRankings();
        model.addAttribute("rankings", rankings);
        //白酒
        ProductType productType = new ProductType();
        productType.setProductTypeName("白酒");
        Product product = new Product();
        product.setProductType(productType);
        List<Product> list = productService.queryProductsByType(product, 5);
        model.addAttribute("list", list);
        //红酒
        productType.setProductTypeName("红酒");
        product.setProductType(productType);
        product.getProductType().setProductTypeName("红酒");
        List<Product> list2 = productService.queryProductsByType(product, 12);
        model.addAttribute("list2", list2);
        //洋酒
        productType.setProductTypeName("洋酒");
        product.setProductType(productType);
        List<Product> list3 = productService.queryProductsByType(product, 5);
        model.addAttribute("list3", list3);
        //养生酒
        productType.setProductTypeName("养生酒");
        product.setProductType(productType);
        List<Product> list4 = productService.queryProductsByType(product, 12);
        model.addAttribute("list4", list4);
        return "front/index/index";
    }
}
package com.yw.eshop.controller.front;
import com.yw.eshop.domain.User;
import com.yw.eshop.service.UserService;
import com.yw.eshop.utils.EncryptionUtils;
import com.yw.eshop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
/**
 * 前端用户登陆退出
 */
@Controller
@RequestMapping("/front/login")
public class FrontLoginController {
    @Autowired
    private UserService userService;
    @RequestMapping("/loginPage")
    public String loginPage(){
        return "front/login";
    }
    @RequestMapping("/login")
    @ResponseBody
    public String login(String username, String password, String code, String autoLogin,
                        HttpServletRequest request, HttpSession session, HttpServletResponse response){
        String code1 = (String) session.getAttribute("code");
        if(StringUtils.isEmpty(code)||!code.equalsIgnoreCase(code1)){
            return "验证码错误";
        }
        if(!StringUtils.isEmpty(username)){
            User user = userService.queryUserByName(username, 1);
            if(user==null){
                return "用户名不存在";
            }else {
                String psw1 = user.getPassword();
                if(psw1.equals(EncryptionUtils.encryptMD5(password))){
                    System.out.println("登录成功");
                    session.setAttribute("user",user);
                    if(!StringUtils.isEmpty(autoLogin)&&autoLogin.equals("1")){
                        Cookie username_cookie = new Cookie("username", username);
                        username_cookie.setMaxAge(3600*24*7);
                        username_cookie.setPath(request.getContextPath());
                        response.addCookie(username_cookie);
                    }else {
                        Cookie username_cookie = new Cookie("username", username);
                        username_cookie.setMaxAge(0);
                        username_cookie.setPath(request.getContextPath());
                        response.addCookie(username_cookie);
                    }
                    return "登录成功";
                }else {
                    return "密码错误";
                }
            }
        }else {
            return "用户名为空";
        }
    }
    @RequestMapping("/logout")
    public void logout(HttpSession session,HttpServletRequest request,HttpServletResponse response) throws IOException {
        session.removeAttribute("user");
        Cookie[] cookies = request.getCookies();
        if(cookies!=null){
            for (Cookie cookie : cookies) {
                if ("username".equals(cookie.getName())) {
                    cookie.setMaxAge(0);
                    cookie.setPath(request.getContextPath());
                    response.addCookie(cookie);
                }
            }
        }
        response.sendRedirect(request.getContextPath()+"/front/login/loginPage");
    }
}
package com.yw.eshop.controller.front;
import com.yw.eshop.domain.Order;
import com.yw.eshop.domain.OrderProduct;
import com.yw.eshop.domain.User;
import com.yw.eshop.service.OrderProductService;
import com.yw.eshop.service.OrderService;
import com.yw.eshop.service.OrderProductService;
import com.yw.eshop.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpSession;
import java.util.List;
/**
 * 前台订单控制器
 */
@Controller
@RequestMapping("front/order")
public class FrontOrderController {
    @Autowired
    private OrderService orderService;
    @Autowired
    private OrderProductService orderProductService;
    /**
     * 前台个人中心订单查询
     * @param session
     * @param model
     * @return
     */
    @RequestMapping("index")
    private String index(HttpSession session, Model model){
        try {
            User user = (User) session.getAttribute("user");
            if (user == null) {
                return "redirect:/front/login/loginPage";
            } else {
                List<Order> list = orderService.queryAllOrder(user.getId());
                for (Order order : list) {
                    List<OrderProduct> orderProducts = orderProductService.queryOrderProByOrderId(order.getId());
                    order.setList(orderProducts);
                }
                model.addAttribute("list", list);
                return "front/order/order";
            }
        }catch (Exception e){
            e.printStackTrace();
            model.addAttribute("errMessage","服务器繁忙"+e.getMessage());
            return "500";
        }
    }
    /**
     *  前台用户取消订单:条件是未发货状态
     * @param id
     * @param model
     * @return
     */
    @RequestMapping("/delete")
    @ResponseBody
    public String delete(String id, Model model){
        model.addAttribute("id", id);
        try {
            int i = orderService.delete(id);
            if (i==0){
                model.addAttribute("errMessage","服务器繁忙操作失败");
                return "500";
            }
        }catch (Exception e){
            model.addAttribute("errMessage",e.getMessage());
            return "500";
        }
        //return "forward:/front/order/index";
        model.addAttribute("url", "/front/order/index");
        return "success";
    }
    /**
     *  前台用户确认收货:条件是己发货状态
     * @param id
     * @param model
     * @return
     */
    @RequestMapping("/update")
    @ResponseBody
    public String update(String id,Integer status, Model model){
        model.addAttribute("id", id);
        try {
            int i = orderService.updateStatus(id,status);
            if (i==0){
                model.addAttribute("errMessage","服务器繁忙操作失败");
                return "500";
            }
        }catch (Exception e){
            model.addAttribute("errMessage",e.getMessage());
            return "500";
        }
        //return "forward:/front/order/index";
        model.addAttribute("url", "/front/order/index");
        return "success";
    }
}
package com.yw.eshop.controller.front;
import com.alibaba.fastjson.JSON;
import com.yw.eshop.domain.*;
import com.yw.eshop.service.*;
import com.yw.eshop.domain.*;
import com.yw.eshop.utils.UUIDUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yw.eshop.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 购物车处理控制品接口
 */
@Controller
@RequestMapping("front/shop_cart")
public class ShopCartController {
    @Autowired
    private ReceiveAddressService receiveAddressService;
    @Autowired
    private ShopCartProductService shopCartProductService;
    @Autowired
    private ShopCartService shopCartService;
    @Autowired
    private OrderService orderService;
    @Autowired
    private OrderProductService orderProductService;
    @RequestMapping("/shopCart")
    public String index(HttpSession session, Model model){
        try{
            User user =(User) session.getAttribute("user");
            if (user ==null){
                return "redirect:/front/login/loginPage";
            }else {
                ShopCart shopCart=shopCartService.queryShopCartByUserID(user.getId());
                List<ReceiveAddress> receiveAddresses=receiveAddressService.queryAddressByUserID(user.getId());
                model.addAttribute("address",receiveAddresses);
                List<ShopCartProduct> list=shopCartProductService.queryCartProductAll(shopCart.getId());
                model.addAttribute("list",list);
            }
            return "front/shop_cart/shop_cart";
        }catch (Exception e){
            e.printStackTrace();
            model.addAttribute("errMessage","服务器繁忙"+e.getMessage());
            return "500";
        }
    }
    @RequestMapping("addProductToCart")
    @ResponseBody
    public String addProductToCart(HttpSession session, String product_id,Integer product_num) throws JsonProcessingException {
        Map map =new HashMap();
        try{
            User user =(User) session.getAttribute("user");
            if (user ==null){
                map.put("message","请登录后再操作");
                map.put("url","/front/login/loginPage");
            }else {
                ShopCart shopCart=shopCartService.queryShopCartByUserID(user.getId());
                ShopCartProduct shopCartProduct=new ShopCartProduct();
                Product product=new Product();
                product.setId(product_id);
                shopCartProduct.setProduct(product);
                shopCartProduct.setShopCart(shopCart);
                shopCartProduct.setProductNum(product_num);
                shopCartProductService.addShop(shopCartProduct);
                map.put("result",true);
            }
        }catch (Exception e){
            e.printStackTrace();
            map.put("message","添加失败"+e.getMessage());
        }
        ObjectMapper objectMapper = new ObjectMapper();
        String val = objectMapper.writeValueAsString(map);
        return val;
    }
    @RequestMapping("/deleteProduct")
    @ResponseBody
    public String delete(String id) throws JsonProcessingException {
        Map map =new HashMap();
        try {
            int i = shopCartProductService.deleteById(id);
            if (i==0){
                map.put("message","删除失败");
            }else {
                map.put("message","删除成功");
                map.put("result",true);
            }
        }catch (Exception e){
            e.printStackTrace();;
            map.put("message","删除失败:"+e.getMessage());
        }
        ObjectMapper objectMapper = new ObjectMapper();
        String val = objectMapper.writeValueAsString(map);
        System.out.println(val);
        return val;
    }
    @RequestMapping("/batchDel")
    @ResponseBody
    public String batchDel(String[] ids) throws JsonProcessingException {
        Map map =new HashMap();
        try {
            shopCartProductService.deleteAll(ids);
            map.put("message","删除成功");
            map.put("result",true);
        }catch (Exception e){
            e.printStackTrace();;
            map.put("message","删除失败:"+e.getMessage());
        }
        ObjectMapper objectMapper = new ObjectMapper();
        String val = objectMapper.writeValueAsString(map);
        System.out.println(val);
        return val;
    }
    @RequestMapping("compute")
    @ResponseBody
    public String compute(String products,String address_id,HttpSession session) throws JsonProcessingException {
        Map map =new HashMap();
        User user =(User) session.getAttribute("user");
        try {
            if (user ==null){
                map.put("message","请登录后再操作");
                map.put("url","/front/login/loginPage");
            }else {
                List<ProIdAndNum> proIdAndNums= JSON.parseArray(products,ProIdAndNum.class);
                Order order=new Order();
                String OrderProId=UUIDUtils.getId();
                order.setId(OrderProId);
                order.setCreateTime(new Date());
                order.setUserId(user.getId());
                ReceiveAddress receiveAddress = new ReceiveAddress();
                receiveAddress.setId(address_id);
                order.setReceiveAddress(receiveAddress);
                orderService.addOrderOne(order);
                ShopCart shopCart=shopCartService.queryShopCartByUserID(user.getId());
                for (ProIdAndNum proIdAndNum : proIdAndNums) {
                    OrderProduct orderProduct=new OrderProduct();
                    orderProduct.setId(UUIDUtils.getId());
                    orderProduct.setOrder(order);
                    Product product=new Product();
                    product.setId(proIdAndNum.getId());
                    orderProduct.setProduct(product);
                    orderProduct.setProductNum(proIdAndNum.getNum());
                    orderProductService.addOrdProOne(orderProduct);
                    shopCartProductService.deleteShopCartBy(shopCart.getId(),proIdAndNum.getId());
                }
                map.put("message","结算成功");
                map.put("result",true);
            }
        }catch (Exception e){
            map.put("message","服务器繁忙:"+e.getMessage());
        }
        ObjectMapper objectMapper = new ObjectMapper();
        String val = objectMapper.writeValueAsString(map);
        System.out.println(val);
        return val;
    }
}

五,项目总结


在目前电商为王的中国社会上,种类繁多的电子商务网站如雨后春笋般纷纷建立,百花齐鸣的发展态势可以在很大程度上,十分有效的解决原来时代的信息资源闭塞和地域上的限制[1]。网上交易代替了很多传统的线下消费,这种势头发展的越来越火热,而这一却都是伴随着用户的购买能力的提高,和IT信息化产业的发展以及新型互联网技术的应用[2]。


互联网以及移动互联网的普及应用,也使得消费者的消费路径更加快捷短暂,足不出户可一缆天下,一机在手可买遍全球。所以消费者基本上已经被新的消费模式所吸引,也具备了网络消费的应用水平。而对于广大的电商平台来讲,大而全的电商有之,小而美的电商也有自己的存活空间[3]。而最近这些年比较流行的垂直电商平台的崛起和应用,也让我们的用户可以直接找到自己所喜欢酒水的平台,进行点对点的消费,这就是我们进行酒水电商研究的一个基础背景[6]。

相关文章
|
1天前
|
Java 关系型数据库 MySQL
【毕业设计】基于Springboot的B2B平台医疗病历交互系统
【毕业设计】基于Springboot的B2B平台医疗病历交互系统
12 0
|
1天前
|
搜索推荐 Java 数据库
springboot集成ElasticSearch的具体操作(系统全文检索)
springboot集成ElasticSearch的具体操作(系统全文检索)
|
1天前
|
前端开发 Java 关系型数据库
Java医院绩效考核系统源码B/S架构+springboot三级公立医院绩效考核系统源码 医院综合绩效核算系统源码
作为医院用综合绩效核算系统,系统需要和his系统进行对接,按照设定周期,从his系统获取医院科室和医生、护士、其他人员工作量,对没有录入信息化系统的工作量,绩效考核系统设有手工录入功能(可以批量导入),对获取的数据系统按照设定的公式进行汇算,且设置审核机制,可以退回修正,系统功能强大,完全模拟医院实际绩效核算过程,且每步核算都可以进行调整和参数设置,能适应医院多种绩效核算方式。
30 2
|
1天前
|
运维 监控 Java
springboot基层区域HIS系统源码
医疗(医院)机构正式使用云HIS系统之前,要先进行院内基础数据的配置,主要在数据管理模块中进行,由系统管理员来操作。
11 0
|
1天前
|
传感器 人工智能 前端开发
JAVA语言VUE2+Spring boot+MySQL开发的智慧校园系统源码(电子班牌可人脸识别)Saas 模式
智慧校园电子班牌,坐落于班级的门口,适合于各类型学校的场景应用,班级学校日常内容更新可由班级自行管理,也可由学校统一管理。让我们一起看看,电子班牌有哪些功能呢?
102 4
JAVA语言VUE2+Spring boot+MySQL开发的智慧校园系统源码(电子班牌可人脸识别)Saas 模式
|
1天前
|
小程序 JavaScript Java
基于SpringBoot+Vue+uniapp微信小程序的4S店客户管理系统的详细设计和实现
基于SpringBoot+Vue+uniapp微信小程序的4S店客户管理系统的详细设计和实现
47 4
|
1天前
|
小程序 JavaScript Java
基于SpringBoot+Vue+uniapp微信小程序的电子商城购物平台的详细设计和实现
基于SpringBoot+Vue+uniapp微信小程序的电子商城购物平台的详细设计和实现
54 3
|
1天前
|
小程序 JavaScript Java
基于SpringBoot+Vue+uniapp微信小程序的汽车保养系统的详细设计和实现
基于SpringBoot+Vue+uniapp微信小程序的汽车保养系统的详细设计和实现
10 1
|
1天前
|
小程序 JavaScript Java
基于SpringBoot+Vue+uniapp微信小程序的童装商城的详细设计和实现
基于SpringBoot+Vue+uniapp微信小程序的童装商城的详细设计和实现
30 1
|
1天前
|
Java Linux
Springboot 解决linux服务器下获取不到项目Resources下资源
Springboot 解决linux服务器下获取不到项目Resources下资源