基于Springboot+Vue實現(xiàn)前后端分離商城管理系統(tǒng)
?作者主頁:
作者簡介:Java領(lǐng)域優(yōu)質(zhì)創(chuàng)作者、CSDN博客專家 、掘金特邀作者、多年架構(gòu)師設(shè)計經(jīng)驗、騰訊課堂常駐講師
主要內(nèi)容:Java項目、畢業(yè)設(shè)計、簡歷模板、學(xué)習(xí)資料、面試題庫、技術(shù)互助
文末獲取源碼?
一,項目簡介
?新新商城,一款基于 Springboot+Vue 的電商項目,前后端分離項目。完整的實現(xiàn)了一個商城系統(tǒng)應(yīng)有的基本功能,包括但不限于以下主要功能模塊:
前端商城用戶
用戶注冊登陸
商品信息分類和品牌瀏覽
全文搜索
添加購物車管理
在線購買商品:使用支付寶沙箱在線支付
個人信息管理
個人訂單管理
在線退換貨功能
退款功能
后臺用戶管理功能
商品分類管理
商品品牌管理
商品規(guī)格管理
商品采購管理
供應(yīng)商管理
訂單管理
退貨退款管理
輪播圖設(shè)置管理
用戶管理
權(quán)限角色管理
個人信息管理
????? 項目后臺基于Springboot+MybatisPlus開發(fā)實現(xiàn),前端使用VUE+Element開發(fā)實現(xiàn),前后端分離開發(fā),前端通過調(diào)用后臺接口來進行相應(yīng)的交互處理。
????? 亮點技術(shù):短信發(fā)送驗證碼、阿里云OSS云存儲商品圖片、郵箱自動發(fā)郵件驗證操作權(quán)限,Shiro權(quán)限管理,數(shù)據(jù)加密處理,支付寶沙箱技術(shù)應(yīng)用,Redis數(shù)據(jù)緩存處理。
??? 項目功能完整,界面優(yōu)雅大方,人機交互流暢,是一個難得的畢業(yè)設(shè)計作品。
二,環(huán)境介紹
語言環(huán)境:Java:? jdk1.8
數(shù)據(jù)庫:Mysql: mysql5.7? Redis:5.0.10
應(yīng)用服務(wù)器:Tomcat:? tomcat8.5.31
開發(fā)工具:IDEA或eclipse
技術(shù)應(yīng)用:
后端技術(shù)
技術(shù)
說明
官網(wǎng)
SpringBoot
容器+MVC框架
Shiro
認(rèn)證和授權(quán)框架
MyBatis
ORM框架
MySQL
數(shù)據(jù)庫
Redis
分布式緩存
Druid
數(shù)據(jù)庫連接池
前端技術(shù)
技術(shù)
說明
官網(wǎng)
Vue
前端框架
Vue-router
路由框架
Vuex
全局狀態(tài)管理框架
Element
前端UI框架
Axios
前端HTTP框架
vue-clipboard2
將內(nèi)容復(fù)制到剪貼板
vuex-persistedstate
vuex持久化
nprogress
進度條控件
開發(fā)環(huán)境
工具
版本號
下載
JDK
1.8
Mysql
5.7
Redis
5.0.10
第三方技術(shù)
工具
官網(wǎng)
支付寶沙箱技術(shù)
OSS 存儲
阿里云短信服務(wù)
QQ郵箱服務(wù)
三,系統(tǒng)展示
下面展示一下項目的主要核心功能:
前端用戶操作
用戶注冊:會對郵箱發(fā)驗證碼驗證,要求必須真實有效郵箱

用戶登陸

首頁


商品購買

購物車

結(jié)算付款


我的訂單:可以申請退款、收貨后可以申請退貨等操作

后臺管理用戶功能
后臺首頁

商品管理:可以實現(xiàn)商品添加、編輯、刪除、下架、查詢等,另可以對商品分類、品牌、規(guī)則、采購信息進行管理,以及對供應(yīng)商進行管理,不再一一展示。菜單上的功能都是齊全的。

訂單管理:可以進行發(fā)貨、退貨、退款等相關(guān)操作

營銷管理
主要對前端展示的廣告輪播圖進行管理

用戶和權(quán)限管理:可以對管理員、顧客、角色進行管理操作

四,核心代碼展示
package com.qiu.controller;import com.alibaba.fastjson.JSON;import com.qiu.entity.Logistics;import com.qiu.entity.Order;import com.qiu.entity.Product;import com.qiu.service.LogisticsService;import com.qiu.service.OrderService;import com.qiu.service.ProductService;import com.qiu.util.general.CommonResult;import org.apache.commons.lang3.StringUtils;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.data.redis.core.RedisTemplate;import org.springframework.web.bind.annotation.CrossOrigin;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;import java.util.ArrayList;import java.util.List;import java.util.Map;import java.util.concurrent.TimeUnit;/**
* @author ZNZ
* @email 469603589@qq.com
* @date 2022/12/28 18:11
* @description 訂單相關(guān)業(yè)務(wù)
*/public class OrderController { ? ?private static final String VIP = "Vip"; ? ?private static final String COLLECT_GOODS_STATE = "已收貨"; ? ?
? ?private OrderService orderService; ? ?
? ?private ProductService productService; ? ?
? ?private LogisticsService logisticsService; ? ?
? ?private RedisTemplate<String, String> redisTemplate; ? ?
? ?public CommonResult findOrderById(Integer orderId) { ? ? ? ?Order order = orderService.selectById(orderId); ? ? ? ?if (orderId != null) { ? ? ? ? ? ?return CommonResult.success("訂單信息查詢成功", order);
? ? ? ?} ? ? ? ?return CommonResult.error("訂單信息查詢失敗");
? ?} ? ?
? ?public CommonResult findOrderInfo(String userAccount) {
? ? ? ?List<Map<String, Object>> orderMap = orderService.selectAllOrder(userAccount); ? ? ? ?if (orderMap != null) { ? ? ? ? ? ?return CommonResult.success("訂單信息查詢成功", orderMap);
? ? ? ?} ? ? ? ?return CommonResult.error("訂單信息查詢失敗");
? ?} ? ?
? ?public CommonResult findAllOrder() {
? ? ? ?List<Order> orders = orderService.selectAll(); ? ? ? ?if (orders != null) { ? ? ? ? ? ?return CommonResult.success("訂單信息查詢成功", orders);
? ? ? ?} ? ? ? ?return CommonResult.error("訂單信息查詢失敗");
? ?} ? ?
? ?public CommonResult findCount() { ? ? ? ?Integer count = orderService.selectCount(); ? ? ? ?if (count != null) { ? ? ? ? ? ?return CommonResult.success("訂單數(shù)量查詢成功", count);
? ? ? ?} ? ? ? ?return CommonResult.error("訂單數(shù)量查詢失敗");
? ?} ? ?
? ?public CommonResult addOrder(Order order) { ? ? ? ?if (order != null) { ? ? ? ? ? ?if (order.getProductNo().contains(VIP)) { ? ? ? ? ? ? ? ?return handleMemberOrders(order);
? ? ? ? ? ?} ? ? ? ? ? ?return handleMerchandiseOrders(order);
? ? ? ?} else { ? ? ? ? ? ?return CommonResult.error("訂單數(shù)據(jù)不完整");
? ? ? ?}
? ?} ? ?
? ?public CommonResult cartOrder(String orderNo, String ordersInfo, String cartIds) {
? ? ? ?List<String> cartIdList = JSON.parseArray(cartIds, String.class);
? ? ? ?List<Order> orders = JSON.parseArray(ordersInfo, Order.class); ? ? ? ?if (orders != null) {
? ? ? ? ? ?ArrayList<String> orderInfo = new ArrayList<>();
? ? ? ? ? ?ArrayList<String> productInfo = new ArrayList<>(); ? ? ? ? ? ?for (Order order : orders) { ? ? ? ? ? ? ? ?Product product = productService.selectByKey(order.getProductNo()); ? ? ? ? ? ? ? ?Integer productStock = product.getProductStock(); ? ? ? ? ? ? ? ?Integer payAmount = order.getPayAmount(); ? ? ? ? ? ? ? ?if (productStock >= payAmount) { ? ? ? ? ? ? ? ? ? ?Product newProduct = new Product();
? ? ? ? ? ? ? ? ? ?newProduct.setProductId(product.getProductId()); ? ? ? ? ? ? ? ? ? ?int newStock = productStock - payAmount;
? ? ? ? ? ? ? ? ? ?newProduct.setProductStock(newStock);
? ? ? ? ? ? ? ? ? ?newProduct.setIsStockOut(newStock < product.getLowestStock()); ? ? ? ? ? ? ? ? ? ?// 如果庫存小于等于0,自動下架
? ? ? ? ? ? ? ? ? ?newProduct.setIsSale(newStock > 0); ? ? ? ? ? ? ? ? ? ?if (productService.updateById(newProduct) && orderService.insertData(order)) {
? ? ? ? ? ? ? ? ? ? ? ?orderInfo.add(order.getOrderNo());
? ? ? ? ? ? ? ? ? ? ? ?productInfo.add(order.getProductNo());
? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?}
? ? ? ? ? ?} ? ? ? ? ? ?if (!orderInfo.isEmpty()) { ? ? ? ? ? ? ? ?String cartIdsInfo = StringUtils.join(cartIdList.toArray(), ","); ? ? ? ? ? ? ? ?String orderNoInfo = StringUtils.join(orderInfo, ","); ? ? ? ? ? ? ? ?String productNoInfo = StringUtils.join(productInfo, ",");
? ? ? ? ? ? ? ?redisTemplate.opsForValue().set(orderNo, orderNoInfo, 24, TimeUnit.HOURS);
? ? ? ? ? ? ? ?redisTemplate.opsForValue().set("cartId" + orderNo, cartIdsInfo, 24, TimeUnit.HOURS); ? ? ? ? ? ? ? ?return CommonResult.success("創(chuàng)建訂單成功", productNoInfo);
? ? ? ? ? ?} ? ? ? ? ? ?return CommonResult.error("創(chuàng)建訂單失敗,請查看商品庫存是否滿足購買數(shù)量");
? ? ? ?} else { ? ? ? ? ? ?return CommonResult.error("訂單數(shù)據(jù)不完整");
? ? ? ?}
? ?} ? ?
? ?public CommonResult updateOrder(Order order) { ? ? ? ?if (orderService.updateById(order)) { ? ? ? ? ? ?return CommonResult.success("修改訂單成功", order);
? ? ? ?} ? ? ? ?return CommonResult.error("修改訂單失敗");
? ?} ? ?
? ?public CommonResult deleteOrder(Integer orderId) { ? ? ? ?if (orderService.deleteById(orderId)) { ? ? ? ? ? ?return CommonResult.success("刪除訂單成功", "訂單id:" + orderId);
? ? ? ?} ? ? ? ?return CommonResult.error("刪除訂單失敗");
? ?} ? ?
? ?public CommonResult updateOrder(Integer orderId) { ? ? ? ?Order order = new Order();
? ? ? ?order.setOrderId(orderId);
? ? ? ?order.setOrderState(COLLECT_GOODS_STATE); ? ? ? ?if (orderService.updateById(order)) { ? ? ? ? ? ?return CommonResult.success("商品收貨成功", order);
? ? ? ?} ? ? ? ?return CommonResult.error("商品收貨失敗");
? ?} ? ?
? ?public CommonResult orderInfo(String orderNo) {
? ? ? ?ArrayList<Object> resultList = new ArrayList<>(); ? ? ? ?Order order = orderService.selectByKey(orderNo); ? ? ? ?Logistics logistics = logisticsService.selectOrderNo(orderNo); ? ? ? ?if (order != null) {
? ? ? ? ? ?resultList.add(order);
? ? ? ?} ? ? ? ?if (logistics != null) {
? ? ? ? ? ?resultList.add(logistics);
? ? ? ?} ? ? ? ?return CommonResult.success("訂單詳情查詢成功", resultList);
? ?} ? ?/**
? ? * 處理會員訂單
? ? *
? ? * @param order 訂單信息
? ? */
? ?private CommonResult handleMemberOrders(Order order) { ? ? ? ?if (orderService.insertData(order)) { ? ? ? ? ? ?return CommonResult.success("創(chuàng)建訂單成功", order);
? ? ? ?} else { ? ? ? ? ? ?return CommonResult.error("創(chuàng)建訂單失敗");
? ? ? ?}
? ?} ? ?/**
? ? * 處理商品訂單
? ? *
? ? * @param order 訂單信息
? ? */
? ?private CommonResult handleMerchandiseOrders(Order order) { ? ? ? ?Product product = productService.selectByKey(order.getProductNo()); ? ? ? ?Integer productStock = product.getProductStock(); ? ? ? ?Integer payAmount = order.getPayAmount(); ? ? ? ?boolean isOk = productStock >= payAmount; ? ? ? ?if (isOk) { ? ? ? ? ? ?Product newProduct = new Product();
? ? ? ? ? ?newProduct.setProductId(product.getProductId()); ? ? ? ? ? ?int newStock = productStock - payAmount;
? ? ? ? ? ?newProduct.setProductStock(newStock);
? ? ? ? ? ?newProduct.setIsStockOut(newStock < product.getLowestStock()); ? ? ? ? ? ?// 如果庫存小于等于0,自動下架
? ? ? ? ? ?newProduct.setIsSale(newStock > 0); ? ? ? ? ? ?if (productService.updateById(newProduct)) { ? ? ? ? ? ? ? ?if (orderService.insertData(order)) {
? ? ? ? ? ? ? ? ? ?redisTemplate.opsForValue().set(order.getOrderNo(), order.getOrderNo(), 24, TimeUnit.HOURS); ? ? ? ? ? ? ? ? ? ?return CommonResult.success("創(chuàng)建訂單成功", order);
? ? ? ? ? ? ? ?} else { ? ? ? ? ? ? ? ? ? ?return CommonResult.error("創(chuàng)建訂單失敗");
? ? ? ? ? ? ? ?}
? ? ? ? ? ?} else { ? ? ? ? ? ? ? ?return CommonResult.error("創(chuàng)建訂單失敗");
? ? ? ? ? ?}
? ? ? ?} else { ? ? ? ? ? ?return CommonResult.error("商品庫存不足");
? ? ? ?}
? ?}
}
package com.qiu.controller;import com.qiu.util.general.CommonResult;import com.qiu.util.oss.AliyunOssUtil;import lombok.extern.slf4j.Slf4j;import org.apache.commons.io.FileUtils;import org.apache.commons.lang3.StringUtils;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 org.springframework.web.multipart.MultipartFile;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;/**
* @author ZNZ
*/public class OssController { ? ?
? ?private AliyunOssUtil ossUtil; ? ?
? ?public CommonResult upload( String folderName, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MultipartFile file)throws IOException { ? ? ? ?if (file != null) { ? ? ? ? ? ?String fileName = file.getOriginalFilename(); ? ? ? ? ? ?if (StringUtils.isNotBlank(fileName)) { ? ? ? ? ? ? ? ?File newFile = new File(fileName); ? ? ? ? ? ? ? ?try (FileOutputStream os = new FileOutputStream(newFile)) {
? ? ? ? ? ? ? ? ? ?os.write(file.getBytes());
? ? ? ? ? ? ? ? ? ?file.transferTo(newFile); ? ? ? ? ? ? ? ? ? ?String path = ossUtil.upload(folderName, newFile);
? ? ? ? ? ? ? ? ? ?log.info("文件上傳成功,路徑:{}", path); ? ? ? ? ? ? ? ? ? ?return new CommonResult(200, "上傳成功", path);
? ? ? ? ? ? ? ?} catch (Exception e) {
? ? ? ? ? ? ? ? ? ?log.error("文件上傳失敗", e); ? ? ? ? ? ? ? ? ? ?return CommonResult.error("上傳失敗");
? ? ? ? ? ? ? ?} finally { ? ? ? ? ? ? ? ? ? ?if (newFile.exists()) {
? ? ? ? ? ? ? ? ? ? ? ?FileUtils.forceDelete(newFile);
? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ?} ? ? ? ?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;/**
* @author ZNZ
* @email 469603589@qq.com
* @date 2022/12/31 16:23
* @description 購物車業(yè)務(wù)類
*/public class ShoppingCartController { ? ?
? ?private ShoppingCartService shoppingCartService; ? ?/**
? ? * 新增商品到購物車
? ? *
? ? * @param shoppingCart 購物車商品信息
? ? */
? ?
? ?public CommonResult addShoppingCart(ShoppingCart shoppingCart) { ? ? ? ?if (shoppingCartService.insertData(shoppingCart)) { ? ? ? ? ? ?return CommonResult.success("購物車添加成功", shoppingCart);
? ? ? ?} ? ? ? ?return CommonResult.error("購物車添加失敗");
? ?} ? ?/**
? ? * 更新購物車商品
? ? *
? ? * @param shoppingCart 購物車商品信息
? ? */
? ?
? ?public CommonResult updateShoppingCart(ShoppingCart shoppingCart) { ? ? ? ?if (shoppingCartService.updateById(shoppingCart)) { ? ? ? ? ? ?return CommonResult.success("購物車修改成功", shoppingCart);
? ? ? ?} ? ? ? ?return CommonResult.error("購物車修改失敗");
? ?} ? ?/**
? ? * 購物車移除商品
? ? *
? ? * @param cartId 購物車商品編號
? ? */
? ?
? ?public CommonResult deleteShoppingCart(Integer cartId) { ? ? ? ?if (shoppingCartService.deleteById(cartId)) { ? ? ? ? ? ?return CommonResult.success("購物車刪除成功", "cartId: " + cartId);
? ? ? ?} ? ? ? ?return CommonResult.error("購物車刪除失敗");
? ?} ? ?/**
? ? * 根據(jù)用戶移除購物車
? ? *
? ? * @param account 用戶賬戶
? ? */
? ?
? ?public CommonResult deleteByUser(String account) { ? ? ? ?if (shoppingCartService.deleteByUser(account)) { ? ? ? ? ? ?return CommonResult.success("購物車刪除成功", account);
? ? ? ?} ? ? ? ?return CommonResult.error("購物車刪除失敗");
? ?} ? ?/**
? ? * 查詢用戶賬號下的購物車信息
? ? *
? ? * @param account 用戶賬戶
? ? */
? ?
? ?public CommonResult findAllShoppingCart(String account) {
? ? ? ?List<Map<String, Object>> shoppingInfo = shoppingCartService.selectAll(account); ? ? ? ?if (shoppingInfo != null) { ? ? ? ? ? ?return CommonResult.success("購物車查詢成功", shoppingInfo);
? ? ? ?} ? ? ? ?return CommonResult.error("購物車查詢失敗");
? ?} ? ?/**
? ? * 根據(jù)購物車商品編號查詢購物車商品信息
? ? *
? ? * @param cartId 購物車商品編號
? ? */
? ?
? ?public CommonResult findById(Integer cartId) { ? ? ? ?ShoppingCart shoppingCart = shoppingCartService.selectById(cartId); ? ? ? ?if (shoppingCart != null) { ? ? ? ? ? ?return CommonResult.success("購物車查詢成功", shoppingCart);
? ? ? ?} ? ? ? ?return CommonResult.error("購物車查詢失敗");
? ?}
}
五,項目總結(jié)
?項目后臺基于Springboot+MybatisPlus開發(fā)實現(xiàn),前端使用VUE+Element開發(fā)實現(xiàn),前后端分離開發(fā),前端通過調(diào)用后臺接口來進行相應(yīng)的交互處理。
????? 亮點技術(shù):短信發(fā)送驗證碼、阿里云OSS云存儲商品圖片、郵箱自動發(fā)郵件驗證操作權(quán)限,Shiro權(quán)限管理,數(shù)據(jù)加密處理,支付寶沙箱技術(shù)應(yīng)用,Redis數(shù)據(jù)緩存處理。
??? 項目功能完整,界面優(yōu)雅大方,人機交互流暢,是一個難得的畢業(yè)設(shè)計作品。