家居建材商城|基于Springboot+Vue实现家居建材商城

作者主页:编程指南针

作者简介:Java领域优质创作者、CSDN博客专家 、掘金特邀作者、多年架构师设计经验、腾讯课堂常驻讲师

主要内容:Java项目、毕业设计、简历模板、学习资料、面试题库、技术互助

收藏点赞不迷路  关注作者有好处

文末获取源码 

项目编号:BS-SC-041

一,项目简介

   

    本系统采用前后端分离开发模式。项目技术应用广泛,涵盖全栈、集群、分布式、高并发;技术应用场景合理,并非多技术的盲目堆叠;业务场景贴近实际,完全按照市场需求开发。 项目前端部分采用html5结合Thymeleaf和vue进行开发,利用WebSocket技术实现用户与商家聊天功能。在前后端数据交互时,使用JavaScript结合axios进行异步调用等进行开发。 项目后端利用MySQL数据库管理系统对数据进行管理。利用Redis数据库存储缓存信息。系统采用SpringBoot框架、MyBatis、MyBatisPlus、lombok日志、druid等进行开发。 ​

本项目主要分为三个模块,分别是系统管理员模块,商家模块以及普通用户模块。

管理员模块:

商家管理:对商家账户信息进行管理,审核新店铺的申请。

用户管理:可以对用户的信息进行修改、删除、添加。

商品管理:对所有的商品进行管理,包括强制下架。

订单管理:对所有的订单进行统一管理。

商家模块:

商品管理:对已经商家的商品进行修改或者上架和下架管理

商铺信息管理:用于商家对本商铺的信息进行管理,比如商店员工和销售情况等。

订单管理:用户商家对商品订单进行发货处理

商家信息维护:商家可以修改商铺的消息策略。

售后管理:用户商家处理一些订单售后申请。

普通用户模块:

登录注册:用户通过该功能进行手机号验证码注册账号与手机验证码账号登录。

商品搜索:用户可以输入需要购买的商品关键词进行查询,系统会查询所有商品信息反馈给用户。

商品查看:选择一个商品后,用户可以点进去查看商品详细信息,包括商家信息、商品图片或者商品。

商品购买:选择好需要的商品及可以下单,填写相关地址信息完,付款后即可完成购买。

与商家在线沟通:在商品详情页面,用户可以选择与商家在线沟通,询问商品的详细情况,比如商品质量以及发货地点,发货时间等。

订单查询:包括查看订单详情、申请售后、取消订单、删除订单等功能。

图 1系统功能模块图

 

本系统采用的是单库单应用架构。前端框架主要利用vue结合elementui进行。利用vue-router将前台页面进行路由。用户触发不同事件的时候,先判断用户是否具有浏览该页面的权限,如果没有权限则拦截页面跳转,同时提示用户没有权限。当用户拥有该权限或者该页面不需要权限的时候,利用Ajax发送异步请求到后台接口,请求后台数据。

请求到达后台后,会被Springmvc的前端控制器进行拦截。然后在业务层找到相应的controller进行处理。然后调用service层处理逻辑事务。然后会调用mybatis的方法对mysql数据库中的数据进行操作。最后将得到得数据一路返回,回到前端经过前台的渲染呈现给用户最终的页面效果。

二,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

后台开发:Springboot+Mybatis

前台开发:Vue+Nodejs+ElementUI

第三方技术:支付宝沙箱、阿里云OSS存储、腾讯云短信发送、邮箱发送等

三,系统展示

前端首页

详情展示

购物车

 我的订单

 个人中心

商家登陆:统计销售情况

商铺基本 信息管理

商品管理

 品牌管理

 商品规格

 查询入库记录

 订单管理

 退换货处理

后台管理员登陆

商铺管理

 商品管理

订单管理

 营销管理-轮播图管理

 营销管理-分类推荐

 用户-角色-权限管理

四,核心代码展示

package com.qiu.controller;

import com.qiu.entity.Role;
import com.qiu.service.RoleService;
import com.qiu.util.general.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户授权等相关业务
 */
@CrossOrigin
@RestController
public class RoleController {
    @Autowired
    private RoleService roleService;

    /**
     * 根据id查询角色信息
     *
     * @param roleId 角色编号
     */
    @RequestMapping(value = "/role/findById")
    public CommonResult findById(Integer roleId) {
        Role role = roleService.selectById(roleId);
        if (role != null) {
            return CommonResult.success("查询成功", role);
        }
        return CommonResult.error("查询失败");
    }

    /**
     * 根据角色名称查询角色
     *
     * @param roleName 角色名称
     */
    @RequestMapping(value = "/role/findByKey")
    public CommonResult findByKey(String roleName) {
        Role role = roleService.selectByKey(roleName);
        if (role != null) {
            return CommonResult.success("查询成功", role);
        }
        return CommonResult.error("查询失败");
    }

    /**
     * 判断角色是否存在
     *
     * @param roleId   角色编号
     * @param roleName 角色名称
     */
    @RequestMapping(value = "/role/existRoleName")
    public CommonResult existRoleName(Integer roleId, String roleName) {
        boolean exist = roleService.existsRoleName(roleId, roleName);
        return CommonResult.success("查询成功", exist);
    }

    /**
     * 查询所有角色信息
     */
    @RequestMapping(value = "/role/findAll")
    public CommonResult findAll() {
        List<Role> roles = roleService.selectAll();
        if (roles != null) {
            return CommonResult.success("查询成功", roles);
        }
        return CommonResult.error("查询失败");
    }

    /**
     * 查询所有可用的角色信息
     */
    @RequestMapping(value = "/role/findAllUsable")
    public CommonResult findAllUsable() {
        List<Role> roles = roleService.selectAllUsable();
        if (roles != null) {
            return CommonResult.success("查询成功", roles);
        }
        return CommonResult.error("查询失败");
    }

    /**
     * 查询角色数量
     */
    @RequestMapping(value = "/role/count")
    public CommonResult findCount() {
        int count = roleService.selectCount();
        return CommonResult.success("查询成功", count);
    }

    /**
     * 新增角色信息
     *
     * @param role 角色信息
     */
    @RequestMapping(value = "/role/add")
    public CommonResult add(Role role) {
        if (role != null) {
            if (roleService.insertData(role)) {
                return CommonResult.success("添加成功", role);
            }
            return CommonResult.error("添加失败");
        }
        return CommonResult.error("角色信息不存在");
    }

    /**
     * 更新角色信息
     *
     * @param role 角色信息
     */
    @RequestMapping(value = "/role/update")
    public CommonResult update(Role role) {
        if (roleService.updateById(role)) {
            return CommonResult.success("更新成功", role);
        }
        return CommonResult.error("更新失败");
    }

    /**
     * 删除角色信息
     *
     * @param roleId 角色编号
     */
    @RequestMapping(value = "/role/delete")
    public CommonResult delete(Integer roleId) {
        if (roleService.deleteById(roleId)) {
            return CommonResult.success("删除成功", roleId);
        }
        return CommonResult.error("删除失败");
    }
}
package com.qiu.controller;

import com.qiu.entity.ShoppingCart;
import com.qiu.service.ShoppingCartService;
import com.qiu.util.general.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 购物车业务类
 */
@RestController
@CrossOrigin
public class ShoppingCartController {

    @Autowired
    private ShoppingCartService shoppingCartService;

    /**
     * 新增商品到购物车
     *
     * @param shoppingCart 购物车商品信息
     */
    @RequestMapping(value = "/shoppingCart/add")
    public CommonResult addShoppingCart(ShoppingCart shoppingCart) {
        if (shoppingCartService.insertData(shoppingCart)) {
            return CommonResult.success("购物车添加成功", shoppingCart);
        }
        return CommonResult.error("购物车添加失败");
    }

    /**
     * 更新购物车商品
     *
     * @param shoppingCart 购物车商品信息
     */
    @RequestMapping(value = "/shoppingCart/update")
    public CommonResult updateShoppingCart(ShoppingCart shoppingCart) {
        if (shoppingCartService.updateById(shoppingCart)) {
            return CommonResult.success("购物车修改成功", shoppingCart);
        }
        return CommonResult.error("购物车修改失败");
    }

    /**
     * 购物车移除商品
     *
     * @param cartId 购物车商品编号
     */
    @RequestMapping(value = "/shoppingCart/deleteById")
    public CommonResult deleteShoppingCart(Integer cartId) {
        if (shoppingCartService.deleteById(cartId)) {
            return CommonResult.success("购物车删除成功", "cartId: " + cartId);
        }
        return CommonResult.error("购物车删除失败");
    }

    /**
     * 根据用户移除购物车
     *
     * @param account 用户账户
     */
    @RequestMapping(value = "/shoppingCart/deleteByUser")
    public CommonResult deleteByUser(String account) {
        if (shoppingCartService.deleteByUser(account)) {
            return CommonResult.success("购物车删除成功", account);
        }
        return CommonResult.error("购物车删除失败");
    }


    /**
     * 查询用户账号下的购物车信息
     *
     * @param account 用户账户
     */
    @RequestMapping(value = "/shoppingCart/findAll")
    public CommonResult findAllShoppingCart(String account) {
        List<Map<String, Object>> shoppingInfo = shoppingCartService.selectAll(account);
        if (shoppingInfo != null) {
            return CommonResult.success("购物车查询成功", shoppingInfo);
        }
        return CommonResult.error("购物车查询失败");
    }

    /**
     * 根据购物车商品编号查询购物车商品信息
     *
     * @param cartId 购物车商品编号
     */
    @RequestMapping(value = "/shoppingCart/findById")
    public CommonResult findById(Integer cartId) {
        ShoppingCart shoppingCart = shoppingCartService.selectById(cartId);
        if (shoppingCart != null) {
            return CommonResult.success("购物车查询成功", shoppingCart);
        }
        return CommonResult.error("购物车查询失败");
    }
}
package com.qiu.controller;

import com.qiu.entity.Product;
import com.qiu.entity.Purchase;
import com.qiu.entity.StoreEntity;
import com.qiu.service.ProductService;
import com.qiu.service.PurchaseService;
import com.qiu.service.StoreService;
import com.qiu.util.general.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

/**
 *  商铺管理和商品入库
 */
@CrossOrigin
@RestController
public class StoreController {

    @Autowired
    private StoreService storeService;

    @Autowired
    private PurchaseService purchaseService;

    @Autowired
    private ProductService productService;

    /**
     * 查询商铺信息
     */
    @RequestMapping(value = "/store/findByStore")
    public CommonResult findByNumber(StoreEntity store) {
        StoreEntity storeEntity = storeService.selectByStore(store);
        if (storeEntity != null) {
            return CommonResult.success("商铺查询成功", storeEntity);
        }
        return CommonResult.error("商铺查询失败");
    }

    /**
     * 查询全部商铺
     */
    @RequestMapping(value = "/store/findAll")
    public CommonResult findAll() {
        List<StoreEntity> stores = storeService.selectAll();
        if (stores != null) {
            return CommonResult.success("商铺查询成功", stores);
        }
        return CommonResult.error("商铺查询失败");
    }

    /**
     * 商铺入驻申请
     * @param store 商铺信息
     */
    @RequestMapping(value = "/store/addStore")
    public CommonResult addStore(StoreEntity store) {
        if (store != null) {
            if (storeService.insertData(store)) {
                return CommonResult.success("店铺入驻申请已发送", store);
            }
            return CommonResult.error("申请发送失败");
        }
        return CommonResult.error("商铺注册数据不存在");
    }

    /**
     * 通过商铺编号更新商铺信息
     *
     * @param store 商铺信息
     */
    @RequestMapping(value = "/store/updateStore")
    public CommonResult updateStoreEntity(StoreEntity store) {
        if (store != null) {
            if (storeService.updateByStore(store)) {
                return CommonResult.success("更新成功", store);
            }
            return CommonResult.error("更新失败");
        }
        return CommonResult.error("商铺数据不存在");
    }

    /**
     * 更新商铺状态
     * @param store 商铺信息
     * @return
     */
    @RequestMapping(value = "/store/updateStoreStatus")
    public CommonResult updateStoreStatus(StoreEntity store) {
        if (store != null) {
            if (storeService.updateStoreStatus(store)) {
                return CommonResult.success("更新成功");
            }
            return CommonResult.error("更新失败");
        }
        return CommonResult.error("商铺数据不存在");
    }

    /**
     * 删除供应商
     * @param storeNumber 供应商编号
     */
    @RequestMapping(value = "/store/deleteStore")
    public CommonResult deleteStoreById(Integer storeNumber) {
        if (storeNumber != null) {
            if (storeService.deleteById(storeNumber)) {
                return CommonResult.success("删除成功", storeNumber);
            }
            return CommonResult.error("删除失败");
        }
        return CommonResult.error("商铺数据不存在");
    }

    //-------------------------------------------商品入库操作------------------------------------------------
    /**
     * 查询入库信息
     * @param purchaseId 入库编号
     */
    @RequestMapping(value = "/purchase/findPurchaseById")
    public CommonResult findPurchaseById(Integer purchaseId) {
        Purchase purchase = purchaseService.selectById(purchaseId);
        if (purchase != null) {
            return CommonResult.success("入库信息查询成功", purchase);
        }
        return CommonResult.error("入库信息查询失败");
    }

    /**
     * 查询全部入库信息
     */
    @RequestMapping(value = "/purchase/findPurchaseAll")
    public CommonResult findPurchaseAll(String accountNumber) {
        List<Purchase> purchases = purchaseService.selectAll(accountNumber);
        if (purchases != null) {
            return CommonResult.success("入库信息查询成功", purchases);
        }
        return CommonResult.error("入库信息查询失败");
    }

    /**
     * 添加入库记录
     * @param purchase 入库信息
     */
    @RequestMapping(value = "/purchase/addPurchase")
    public CommonResult addPurchase(Purchase purchase) {
        if (purchase != null) {
            //1.添加商品库存
            Integer productId = productService.selectIdByKey(purchase.getProductNo());
            Product product = productService.selectById(productId);
            Integer lowestStock = product.getLowestStock();
            Integer productStock = product.getProductStock();
            Integer purchaseNumber =Integer.parseInt(purchase.getPurchaseNumber());
            product.setProductStock(productStock + purchaseNumber);
            product.setIsStockOut(product.getProductStock() < lowestStock);
            if (productService.updateById(product)) {//库存信息更新成功
                purchaseService.insertData(purchase);//插入一条入库记录
                return CommonResult.success("商品入库成功", purchase);
            }
            return CommonResult.error("商品库存更新失败");
        }
        return CommonResult.error("系统繁忙,请稍后再试!");
    }

    /**
     * 删除入库记录
     *
     * @param purchaseId 入库id
     */
    @RequestMapping(value = "/purchase/deletePurchase")
    public CommonResult deletePurchase(Integer purchaseId) {
        if (purchaseId != null) {
            if (purchaseService.deleteById(purchaseId)) {
                return CommonResult.success("删除成功", purchaseId);
            }
            return CommonResult.error("删除失败");
        }
        return CommonResult.error("入库信息数据不存在,请刷新重试");
    }

}

package com.qiu.controller;

import com.qiu.constant.UserStatusEnum;
import com.qiu.entity.User;
import com.qiu.entity.UserRole;
import com.qiu.entity.Vip;
import com.qiu.service.UserRoleService;
import com.qiu.service.UserService;
import com.qiu.service.VipService;
import com.qiu.util.general.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 *  用户相关业务
 */
@CrossOrigin
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private UserRoleService userRoleService;

    @Autowired
    private VipService vipService;

    /**
     * 根据id查询用户
     *
     * @param id 用户编号
     */
    @RequestMapping(value = "/user/findById")
    public CommonResult findById(Integer id) {
        User user = userService.selectById(id);
        if (user != null) {
            return CommonResult.success("查询成功", user);
        } else {
            return CommonResult.error("查询失败");
        }
    }

    /**
     * 根据账号查询用户
     *
     * @param key 账号
     */
    @RequestMapping(value = "/user/findByKey")
    public CommonResult findByKey(String key) {
        User user = userService.selectByKey(key);
        if (user != null) {
            return CommonResult.success("查询成功", user);
        }
        return CommonResult.error("查询失败");
    }

    /**
     * 查询所有顾客
     */
    @RequestMapping(value = "/user/findAll/customer")
    public CommonResult findAllCustomer() {
        List<User> users = userService.queryAllByStatus(UserStatusEnum.CUSTOMER);
        if (users != null) {
            return CommonResult.success("查询成功", users);
        }
        return CommonResult.error("查询失败");
    }

    /**
     * 查询所有管理员
     */
    @RequestMapping(value = "/user/findAll/admin")
    public CommonResult findAllAdmin() {
        List<User> users = userService.queryAllByStatus(UserStatusEnum.ADMIN);
        if (users != null) {
            return CommonResult.success("查询成功", users);
        }
        return CommonResult.error("查询失败");
    }

//    /**
//     * 查询商家的商铺编号
//     */
//    @RequestMapping(value = "/user/storeNumber")
//    public CommonResult findStoreNumber(String accountNumber) {
//        String storeNumber= userService.selectStoreNumber(accountNumber);
//        if (storeNumber != null) {
//            return CommonResult.success("商铺编号查询成功", storeNumber);
//        }
//        return CommonResult.error("商铺编号查询失败");
//    }

    /**
     * 判断某个用户是否还存在
     *
     * @param key 账号
     */
    @RequestMapping(value = "/user/existKey")
    public CommonResult existKey(String key) {
        boolean exist = userService.existsWithPrimaryKey(key);
        return CommonResult.success("查询成功", exist);
    }

    /**
     * 查询用户状态
     *
     * @param accountNumber 用户账号
     */
    @RequestMapping(value = "/user/userState")
    public CommonResult userState(String accountNumber) {
        boolean state = userService.selectUserState(accountNumber);
        return CommonResult.success("查询成功", state);
    }

    /**
     * 查询用户记录的总个数
     */
    @RequestMapping(value = "/user/count")
    public CommonResult findCount() {
        int count = userService.selectCount();
        return CommonResult.success("查询成功", count);

    }

    /**
     * 通过用户账号查询用户ID
     *
     * @param key 用户账号
     */
    @RequestMapping(value = "/user/findIdByKey")
    public CommonResult findIdByKey(String key) {
        Integer id = userService.selectIdByKey(key);
        if (id != null) {
            return CommonResult.success("查询成功", id);
        }
        return CommonResult.error("未查询到");
    }

    /**
     * 删除用户
     *
     * @param userId 用户编号
     */
    @RequestMapping(value = "/user/delete")
    public CommonResult delete(Integer userId) {
        if (userService.deleteById(userId)) {
            return CommonResult.success("删除成功", userId);
        }
        return CommonResult.error("删除失败");
    }

    /**
     * 角色授权
     *
     * @param userId 用户编号
     * @param roleId 角色编号列表
     */
    @RequestMapping(value = "/user/author")
    public CommonResult author(Integer userId, @RequestParam List<Integer> roleId) {
        if (userId != null && roleId != null && !roleId.isEmpty()) {
            if (userRoleService.deleteById(userId)) {
                UserRole userRole = new UserRole();
                userRole.setUserId(userId);
                for (Integer id : roleId) {
                    userRole.setRoleId(id);
                    userRoleService.insertData(userRole);
                }
            }
            User user = new User();
            user.setUserId(userId);
            user.setStatus(UserStatusEnum.ADMIN);
            userService.updateById(user);
            return CommonResult.success("授权成功");
        } else {
            return CommonResult.error("角色授权数据不完整!");
        }
    }

    /**
     * 查询所有VIP用户
     */
    @RequestMapping(value = "/vip/findAllVip")
    public CommonResult findAllVip() {
        List<Vip> vips = vipService.selectAll();
        if (vips != null) {
            return CommonResult.success("查询成功", vips);
        }
        return CommonResult.error("查询失败");
    }

    /**
     * 查询VIP用户信息根据id
     *
     * @param vipId 会员编号
     */
    @RequestMapping(value = "/vip/findVipById")
    public CommonResult findVipById(Integer vipId) {
        Vip vip = vipService.selectById(vipId);
        if (vip != null) {
            return CommonResult.success("查询成功", vip);
        }
        return CommonResult.error("查询失败");
    }

    /**
     * 查询VIP用户信息根据id
     *
     * @param accountNumber 用户账号
     */
    @RequestMapping(value = "/vip/findVipByKey")
    public CommonResult findVipByKey(String accountNumber) {
        Vip vip = vipService.selectByKey(accountNumber);
        if (vip != null) {
            return CommonResult.success("查询成功", vip);
        }
        return CommonResult.error("查询失败");
    }

    /**
     * 判断用户信息是否存在
     *
     * @param accountNumber 用户账号
     */
    @RequestMapping(value = "/vip/existsVip")
    public CommonResult existsVip(String accountNumber) {
        boolean exist = vipService.existsVip(accountNumber);
        return CommonResult.success("查询成功", exist);
    }

    /**
     * 增加会员信息
     *
     * @param vip 会员信息
     */
    @RequestMapping(value = "/vip/addVip")
    public CommonResult addVip(Vip vip) {
        Date date = new Date();
        Calendar cal = Calendar.getInstance();
        //设置起时间
        cal.setTime(date);
        //增加一年
        cal.add(Calendar.YEAR, 1);
        vip.setOverdueTime(cal.getTime());
        if (vipService.insertData(vip)) {
            return CommonResult.success("会员信息添加成功", vip);
        }
        return CommonResult.error("会员信息添加失败");
    }

    /**
     * 更新会员信息
     *
     * @param vip 会员信息
     */
    @RequestMapping(value = "/vip/updateVip")
    public CommonResult updateVip(Vip vip) {
        if (vipService.updateById(vip)) {
            return CommonResult.success("会员信息更新成功", vip);
        }
        return CommonResult.error("会员信息更新失败");
    }

    /**
     * 清除信息
     *
     * @param vipId 会员编号
     */
    @RequestMapping(value = "/vip/deleteVip")
    public CommonResult deleteVip(Integer vipId) {
        if (vipService.deleteById(vipId)) {
            return CommonResult.success("删除成功", vipId);
        }
        return CommonResult.error("删除失败");
    }
}

五,项目总结

 表结构及ER图

本系统用到了18张表存储数据,分别是banner(商品广告轮播图表)、

Logistics(物流表)、order(订单表)、product(商品表)、product_brand(商品品牌表)、product_review(商品评价表)、product_specs(商品规格表)、product_type(商品类型推荐表)、purchase(商品入库记录表)、return_goods(商品退货表)、return_reason(退货原因表)、role(角色表)、shopping_cart(购物车表)、specs(商品规格表)、store(商铺信息表)、sys_commodity_type(商品类型表)、user(用户表)、user_role(用户角色表)。

猜你喜欢

转载自blog.csdn.net/whirlwind526/article/details/128770671