当前位置:   article > 正文

咖啡商城|基于Springboot+Vue前后端分离咖啡商城系统_前后端分离的商城项目

前后端分离的商城项目

作者主页:编程指南针

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

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

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

文末获取源码 

项目编号:BS-SC-042

前言:

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

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

一,项目简介

本项目基于Spring Boot搭建的咖啡商城系统主要有用户管理功能、商品管理功能、购物车管理功能、订单管理功能、角色管理功能等,一共分为七个大的核心模块:

前台管理系统:

(1)用户功能模块:用户可以进行登录注册与注销操作,并且可以对个人信息进行响应的修改。

(2)商品功能模块:用户可以搜索查看自己想要的商品,也可以点击商品进行查看商品的详细信息。

(3)购物车管理模块:用户可以把自己感兴趣的商品加入购物车,点击购物车查看购物车信息,可以的对购物车内的商品进行修改,用账号余额对购物车进行结算。

(4)订单功能模块:用户点击订单查看自己的所有订单信息,看到当前订单状态,对已完成的订单进行评价。

后台管理系统:

(5)用户管理模块:管理员可以对普通用户信息进行相应的增删改查操作。

(6)商品资讯管理:管理员可以对商品资讯进行相应的增删改查操作,向用户进行商品推荐。

(7)商品管理模块:管理员可以对商品的信息进行修改,增加新的商品,删除掉不用的商品。

(8)轮播图管理模块:管理员可以对轮播图的信息进行修改,增加新的轮播图,根据优惠在首页显示推荐商品轮播图,实时修改轮播图信息。

二,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

后台开发技术:Springboot+Mybatis

前台开发技术:Vue+nodejs+ElementUI

特色:支付宝沙箱支付、前后端分离开发

三,系统展示

系统首页

分类展示

 商品详情

前端用户注册登陆

 购物车

下单支付:点支付从充值卡里扣除,如不够则进入支付宝沙箱支付平台

 商品资讯

 个人中心:可以实现在线充值

 我的订单

用户管理

商品分类管理

商品管理

 评价管理

轮播图管理

商品资讯

四,核心代码展示

  1. package com.controller;
  2. import java.io.File;
  3. import java.io.FileNotFoundException;
  4. import java.io.IOException;
  5. import java.util.Arrays;
  6. import java.util.Date;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10. import java.util.Random;
  11. import java.util.UUID;
  12. import org.apache.commons.io.FileUtils;
  13. import org.apache.commons.lang3.StringUtils;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.http.HttpHeaders;
  16. import org.springframework.http.HttpStatus;
  17. import org.springframework.http.MediaType;
  18. import org.springframework.http.ResponseEntity;
  19. import org.springframework.util.ResourceUtils;
  20. import org.springframework.web.bind.annotation.PathVariable;
  21. import org.springframework.web.bind.annotation.RequestBody;
  22. import org.springframework.web.bind.annotation.RequestMapping;
  23. import org.springframework.web.bind.annotation.RequestParam;
  24. import org.springframework.web.bind.annotation.RestController;
  25. import org.springframework.web.multipart.MultipartFile;
  26. import com.annotation.IgnoreAuth;
  27. import com.baomidou.mybatisplus.mapper.EntityWrapper;
  28. import com.entity.ConfigEntity;
  29. import com.entity.EIException;
  30. import com.service.ConfigService;
  31. import com.utils.R;
  32. /**
  33. * 上传文件映射表
  34. */
  35. @RestController
  36. @RequestMapping("file")
  37. @SuppressWarnings({"unchecked","rawtypes"})
  38. public class FileController{
  39. @Autowired
  40. private ConfigService configService;
  41. /**
  42. * 上传文件
  43. */
  44. @RequestMapping("/upload")
  45. public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
  46. if (file.isEmpty()) {
  47. throw new EIException("上传文件不能为空");
  48. }
  49. String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
  50. //File path = new File(ResourceUtils.getURL("classpath:static").getPath());
  51. String path2 = ResourceUtils.getFile("classpath:static").getAbsolutePath();
  52. /*if(!path.exists()) {
  53. path = new File("");
  54. }*/
  55. File upload = new File(path2,"/upload/");
  56. if(!upload.exists()) {
  57. upload.mkdirs();
  58. }
  59. String fileName = new Date().getTime()+"."+fileExt;
  60. File dest = new File(upload.getAbsolutePath()+"/"+fileName);
  61. file.transferTo(dest);
  62. if(StringUtils.isNotBlank(type) && type.equals("1")) {
  63. ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
  64. if(configEntity==null) {
  65. configEntity = new ConfigEntity();
  66. configEntity.setName("faceFile");
  67. configEntity.setValue(fileName);
  68. } else {
  69. configEntity.setValue(fileName);
  70. }
  71. configService.insertOrUpdate(configEntity);
  72. }
  73. return R.ok().put("file", fileName);
  74. }
  75. /**
  76. * 下载文件
  77. */
  78. @IgnoreAuth
  79. @RequestMapping("/download")
  80. public ResponseEntity<byte[]> download(@RequestParam String fileName) {
  81. try {
  82. File path = new File(ResourceUtils.getURL("classpath:static").getPath());
  83. if(!path.exists()) {
  84. path = new File("");
  85. }
  86. File upload = new File(path.getAbsolutePath(),"/upload/");
  87. if(!upload.exists()) {
  88. upload.mkdirs();
  89. }
  90. File file = new File(upload.getAbsolutePath()+"/"+fileName);
  91. if(file.exists()){
  92. /*if(!fileService.canRead(file, SessionManager.getSessionUser())){
  93. getResponse().sendError(403);
  94. }*/
  95. HttpHeaders headers = new HttpHeaders();
  96. headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
  97. headers.setContentDispositionFormData("attachment", fileName);
  98. return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
  99. }
  100. } catch (IOException e) {
  101. e.printStackTrace();
  102. }
  103. return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
  104. }
  105. }

  1. package com.controller;
  2. import java.text.SimpleDateFormat;
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5. import java.util.Calendar;
  6. import java.util.Map;
  7. import java.util.HashMap;
  8. import java.util.Iterator;
  9. import java.util.Date;
  10. import java.util.List;
  11. import javax.servlet.http.HttpServletRequest;
  12. import com.utils.ValidatorUtils;
  13. import org.apache.commons.lang3.StringUtils;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.format.annotation.DateTimeFormat;
  16. import org.springframework.web.bind.annotation.PathVariable;
  17. import org.springframework.web.bind.annotation.RequestBody;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.bind.annotation.RequestParam;
  20. import org.springframework.web.bind.annotation.RestController;
  21. import com.baomidou.mybatisplus.mapper.EntityWrapper;
  22. import com.baomidou.mybatisplus.mapper.Wrapper;
  23. import com.annotation.IgnoreAuth;
  24. import com.entity.OrdersEntity;
  25. import com.entity.view.OrdersView;
  26. import com.service.OrdersService;
  27. import com.service.TokenService;
  28. import com.utils.PageUtils;
  29. import com.utils.R;
  30. import com.utils.MD5Util;
  31. import com.utils.MPUtil;
  32. import com.utils.CommonUtil;
  33. /**
  34. * 订单
  35. * 后端接口
  36. * @author
  37. * @email
  38. * @date 2021-03-13 12:49:52
  39. */
  40. @RestController
  41. @RequestMapping("/orders")
  42. public class OrdersController {
  43. @Autowired
  44. private OrdersService ordersService;
  45. /**
  46. * 后端列表
  47. */
  48. @RequestMapping("/page")
  49. public R page(@RequestParam Map<String, Object> params,OrdersEntity orders,
  50. HttpServletRequest request){
  51. if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
  52. orders.setUserid((Long)request.getSession().getAttribute("userId"));
  53. }
  54. EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>();
  55. PageUtils page = ordersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, orders), params), params));
  56. return R.ok().put("data", page);
  57. }
  58. /**
  59. * 前端列表
  60. */
  61. @RequestMapping("/list")
  62. public R list(@RequestParam Map<String, Object> params,OrdersEntity orders, HttpServletRequest request){
  63. EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>();
  64. PageUtils page = ordersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, orders), params), params));
  65. return R.ok().put("data", page);
  66. }
  67. /**
  68. * 列表
  69. */
  70. @RequestMapping("/lists")
  71. public R list( OrdersEntity orders){
  72. EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>();
  73. ew.allEq(MPUtil.allEQMapPre( orders, "orders"));
  74. return R.ok().put("data", ordersService.selectListView(ew));
  75. }
  76. /**
  77. * 查询
  78. */
  79. @RequestMapping("/query")
  80. public R query(OrdersEntity orders){
  81. EntityWrapper< OrdersEntity> ew = new EntityWrapper< OrdersEntity>();
  82. ew.allEq(MPUtil.allEQMapPre( orders, "orders"));
  83. OrdersView ordersView = ordersService.selectView(ew);
  84. return R.ok("查询订单成功").put("data", ordersView);
  85. }
  86. /**
  87. * 后端详情
  88. */
  89. @RequestMapping("/info/{id}")
  90. public R info(@PathVariable("id") Long id){
  91. OrdersEntity orders = ordersService.selectById(id);
  92. return R.ok().put("data", orders);
  93. }
  94. /**
  95. * 前端详情
  96. */
  97. @RequestMapping("/detail/{id}")
  98. public R detail(@PathVariable("id") Long id){
  99. OrdersEntity orders = ordersService.selectById(id);
  100. return R.ok().put("data", orders);
  101. }
  102. /**
  103. * 后端保存
  104. */
  105. @RequestMapping("/save")
  106. public R save(@RequestBody OrdersEntity orders, HttpServletRequest request){
  107. orders.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
  108. //ValidatorUtils.validateEntity(orders);
  109. orders.setUserid((Long)request.getSession().getAttribute("userId"));
  110. ordersService.insert(orders);
  111. return R.ok();
  112. }
  113. /**
  114. * 前端保存
  115. */
  116. @RequestMapping("/add")
  117. public R add(@RequestBody OrdersEntity orders, HttpServletRequest request){
  118. orders.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
  119. //ValidatorUtils.validateEntity(orders);
  120. ordersService.insert(orders);
  121. return R.ok();
  122. }
  123. /**
  124. * 修改
  125. */
  126. @RequestMapping("/update")
  127. public R update(@RequestBody OrdersEntity orders, HttpServletRequest request){
  128. //ValidatorUtils.validateEntity(orders);
  129. ordersService.updateById(orders);//全部更新
  130. return R.ok();
  131. }
  132. /**
  133. * 删除
  134. */
  135. @RequestMapping("/delete")
  136. public R delete(@RequestBody Long[] ids){
  137. ordersService.deleteBatchIds(Arrays.asList(ids));
  138. return R.ok();
  139. }
  140. /**
  141. * 提醒接口
  142. */
  143. @RequestMapping("/remind/{columnName}/{type}")
  144. public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
  145. @PathVariable("type") String type,@RequestParam Map<String, Object> map) {
  146. map.put("column", columnName);
  147. map.put("type", type);
  148. if(type.equals("2")) {
  149. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  150. Calendar c = Calendar.getInstance();
  151. Date remindStartDate = null;
  152. Date remindEndDate = null;
  153. if(map.get("remindstart")!=null) {
  154. Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
  155. c.setTime(new Date());
  156. c.add(Calendar.DAY_OF_MONTH,remindStart);
  157. remindStartDate = c.getTime();
  158. map.put("remindstart", sdf.format(remindStartDate));
  159. }
  160. if(map.get("remindend")!=null) {
  161. Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
  162. c.setTime(new Date());
  163. c.add(Calendar.DAY_OF_MONTH,remindEnd);
  164. remindEndDate = c.getTime();
  165. map.put("remindend", sdf.format(remindEndDate));
  166. }
  167. }
  168. Wrapper<OrdersEntity> wrapper = new EntityWrapper<OrdersEntity>();
  169. if(map.get("remindstart")!=null) {
  170. wrapper.ge(columnName, map.get("remindstart"));
  171. }
  172. if(map.get("remindend")!=null) {
  173. wrapper.le(columnName, map.get("remindend"));
  174. }
  175. if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
  176. wrapper.eq("userid", (Long)request.getSession().getAttribute("userId"));
  177. }
  178. int count = ordersService.selectCount(wrapper);
  179. return R.ok().put("count", count);
  180. }
  181. }
  1. package com.controller;
  2. import java.text.SimpleDateFormat;
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5. import java.util.Calendar;
  6. import java.util.Map;
  7. import java.util.HashMap;
  8. import java.util.Iterator;
  9. import java.util.Date;
  10. import java.util.List;
  11. import javax.servlet.http.HttpServletRequest;
  12. import com.utils.ValidatorUtils;
  13. import org.apache.commons.lang3.StringUtils;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.format.annotation.DateTimeFormat;
  16. import org.springframework.web.bind.annotation.PathVariable;
  17. import org.springframework.web.bind.annotation.RequestBody;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.bind.annotation.RequestParam;
  20. import org.springframework.web.bind.annotation.RestController;
  21. import com.baomidou.mybatisplus.mapper.EntityWrapper;
  22. import com.baomidou.mybatisplus.mapper.Wrapper;
  23. import com.annotation.IgnoreAuth;
  24. import com.entity.StoreupEntity;
  25. import com.entity.view.StoreupView;
  26. import com.service.StoreupService;
  27. import com.service.TokenService;
  28. import com.utils.PageUtils;
  29. import com.utils.R;
  30. import com.utils.MD5Util;
  31. import com.utils.MPUtil;
  32. import com.utils.CommonUtil;
  33. /**
  34. * 收藏表
  35. * 后端接口
  36. * @author
  37. * @email
  38. * @date 2021-03-13 12:49:52
  39. */
  40. @RestController
  41. @RequestMapping("/storeup")
  42. public class StoreupController {
  43. @Autowired
  44. private StoreupService storeupService;
  45. /**
  46. * 后端列表
  47. */
  48. @RequestMapping("/page")
  49. public R page(@RequestParam Map<String, Object> params,StoreupEntity storeup,
  50. HttpServletRequest request){
  51. if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
  52. storeup.setUserid((Long)request.getSession().getAttribute("userId"));
  53. }
  54. EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
  55. PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
  56. return R.ok().put("data", page);
  57. }
  58. /**
  59. * 前端列表
  60. */
  61. @RequestMapping("/list")
  62. public R list(@RequestParam Map<String, Object> params,StoreupEntity storeup, HttpServletRequest request){
  63. if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
  64. storeup.setUserid((Long)request.getSession().getAttribute("userId"));
  65. }
  66. EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
  67. PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
  68. return R.ok().put("data", page);
  69. }
  70. /**
  71. * 列表
  72. */
  73. @RequestMapping("/lists")
  74. public R list( StoreupEntity storeup){
  75. EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
  76. ew.allEq(MPUtil.allEQMapPre( storeup, "storeup"));
  77. return R.ok().put("data", storeupService.selectListView(ew));
  78. }
  79. /**
  80. * 查询
  81. */
  82. @RequestMapping("/query")
  83. public R query(StoreupEntity storeup){
  84. EntityWrapper< StoreupEntity> ew = new EntityWrapper< StoreupEntity>();
  85. ew.allEq(MPUtil.allEQMapPre( storeup, "storeup"));
  86. StoreupView storeupView = storeupService.selectView(ew);
  87. return R.ok("查询收藏表成功").put("data", storeupView);
  88. }
  89. /**
  90. * 后端详情
  91. */
  92. @RequestMapping("/info/{id}")
  93. public R info(@PathVariable("id") Long id){
  94. StoreupEntity storeup = storeupService.selectById(id);
  95. return R.ok().put("data", storeup);
  96. }
  97. /**
  98. * 前端详情
  99. */
  100. @RequestMapping("/detail/{id}")
  101. public R detail(@PathVariable("id") Long id){
  102. StoreupEntity storeup = storeupService.selectById(id);
  103. return R.ok().put("data", storeup);
  104. }
  105. /**
  106. * 后端保存
  107. */
  108. @RequestMapping("/save")
  109. public R save(@RequestBody StoreupEntity storeup, HttpServletRequest request){
  110. storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
  111. //ValidatorUtils.validateEntity(storeup);
  112. storeup.setUserid((Long)request.getSession().getAttribute("userId"));
  113. storeupService.insert(storeup);
  114. return R.ok();
  115. }
  116. /**
  117. * 前端保存
  118. */
  119. @RequestMapping("/add")
  120. public R add(@RequestBody StoreupEntity storeup, HttpServletRequest request){
  121. storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
  122. //ValidatorUtils.validateEntity(storeup);
  123. storeup.setUserid((Long)request.getSession().getAttribute("userId"));
  124. storeupService.insert(storeup);
  125. return R.ok();
  126. }
  127. /**
  128. * 修改
  129. */
  130. @RequestMapping("/update")
  131. public R update(@RequestBody StoreupEntity storeup, HttpServletRequest request){
  132. //ValidatorUtils.validateEntity(storeup);
  133. storeupService.updateById(storeup);//全部更新
  134. return R.ok();
  135. }
  136. /**
  137. * 删除
  138. */
  139. @RequestMapping("/delete")
  140. public R delete(@RequestBody Long[] ids){
  141. storeupService.deleteBatchIds(Arrays.asList(ids));
  142. return R.ok();
  143. }
  144. /**
  145. * 提醒接口
  146. */
  147. @RequestMapping("/remind/{columnName}/{type}")
  148. public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
  149. @PathVariable("type") String type,@RequestParam Map<String, Object> map) {
  150. map.put("column", columnName);
  151. map.put("type", type);
  152. if(type.equals("2")) {
  153. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  154. Calendar c = Calendar.getInstance();
  155. Date remindStartDate = null;
  156. Date remindEndDate = null;
  157. if(map.get("remindstart")!=null) {
  158. Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
  159. c.setTime(new Date());
  160. c.add(Calendar.DAY_OF_MONTH,remindStart);
  161. remindStartDate = c.getTime();
  162. map.put("remindstart", sdf.format(remindStartDate));
  163. }
  164. if(map.get("remindend")!=null) {
  165. Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
  166. c.setTime(new Date());
  167. c.add(Calendar.DAY_OF_MONTH,remindEnd);
  168. remindEndDate = c.getTime();
  169. map.put("remindend", sdf.format(remindEndDate));
  170. }
  171. }
  172. Wrapper<StoreupEntity> wrapper = new EntityWrapper<StoreupEntity>();
  173. if(map.get("remindstart")!=null) {
  174. wrapper.ge(columnName, map.get("remindstart"));
  175. }
  176. if(map.get("remindend")!=null) {
  177. wrapper.le(columnName, map.get("remindend"));
  178. }
  179. if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
  180. wrapper.eq("userid", (Long)request.getSession().getAttribute("userId"));
  181. }
  182. int count = storeupService.selectCount(wrapper);
  183. return R.ok().put("count", count);
  184. }
  185. }

五,项目总结

基于Springboot实现的咖啡商城网站是一种网络销售模式,将传统的咖啡展示与购买从线上搬到了线上,它解决传统电子产品实体店地域的限制和要求,方便人们足不出户进行产品的购买和消费。具体研究有如下意义:

(1)解决线下单店区域限制的问题,可以实现全域覆盖。

(2)线上销售的总体成本在低于线下实体店,可以有更有竞争力的价格优势。

(3)随着技术的发展,线上的产品浏览体验也越来越好,可以更加方便用户进行对比

(4)疫情当下,线上消费可以实现无接触配送,更加安全高效。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/456026
推荐阅读
相关标签
  

闽ICP备14008679号