源码获取:博客首页 "资源" 里下载!

一、项目简述

本系统功能包括: 前台展示+后台管理,包括最基本的用户登录注册,下单, 购物车,购买,结算,订单查询,收货地址,后台商品管 理,订单管理,用户管理等等功能,小伙伴一起来看看 吧。

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX (Webstorm也 行)+ Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts都支 持)。

项目技术: Springboot + Maven + Mybatis + Vue + Redis + HTML 等 等组成,B/S模式+ Maven管理等等。

订单相关业务:

package com.qiu.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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.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;/*** @description 订单相关业务*/@RestController
@CrossOrigin
public class OrderController {final OrderService orderService;final ProductService productService;final LogisticsService logisticsService;final RedisTemplate<String,String> redisTemplate;public OrderController(RedisTemplate<String,String> redisTemplate,OrderService orderService,LogisticsService logisticsService,ProductService productService) {this.orderService = orderService;this.productService = productService;this.logisticsService = logisticsService;this.redisTemplate = redisTemplate;}@RequestMapping(value = "/order/findById")private CommonResult findOrderById(Integer orderId) {Order order= orderService.selectById(orderId);if(orderId!=null){return CommonResult.success("订单信息查询成功",order);}else{return CommonResult.error("订单信息查询失败");}}@RequestMapping(value = "/order/findOrderInfo")private CommonResult findOrderInfo(String userAccount) {List<Map<String, Object>> orderMap = orderService.selectAllOrder(userAccount);if(orderMap!=null){return CommonResult.success("订单信息查询成功",orderMap);}else{return CommonResult.error("订单信息查询失败");}}@RequestMapping(value = "/order/findAll")private CommonResult findAllOrder() {List<Order> orders = orderService.selectAll();System.out.println(orders);if(orders!=null){return CommonResult.success("订单信息查询成功",orders);}else{return CommonResult.error("订单信息查询失败");}}@RequestMapping(value = "/order/findCount")private CommonResult findCount() {Integer count = orderService.selectCount();if(count!=null){return CommonResult.success("订单数量查询成功",count);}else{return CommonResult.error("订单数量查询失败");}}@RequestMapping(value = "/order/add")private CommonResult addOrder(Order order) {if(order!=null){if(order.getProductNo().contains("Vip")){if(orderService.insertData(order)){return CommonResult.success("创建订单成功",order);}else{return CommonResult.error("创建订单失败");}}else{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("创建订单成功",order);}else{return CommonResult.error("创建订单失败");}}else{return CommonResult.error("创建订单失败");}}else{return CommonResult.error("商品库存不足");}}}else{return CommonResult.error("订单数据不完整");}}@RequestMapping(value = "/order/cartOrder")private CommonResult cartOrder(String orderNo,String ordersInfo) {JSONArray jsonArray = JSON.parseArray(ordersInfo);List<Order> orders = JSONObject.parseArray(jsonArray.toJSONString(), 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();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)){orderInfo.add(order.getOrderNo());productInfo.add(order.getProductNo());}}}}if(orderInfo.size()!=0){String orderNoInfo = StringUtils.join(orderInfo, ",");String productNoInfo = StringUtils.join(productInfo, ",");redisTemplate.opsForValue().set(orderNo,orderNoInfo,24, TimeUnit.HOURS);return CommonResult.success("创建订单成功",productNoInfo);}else{return CommonResult.success("创建订单失败");}}else{return CommonResult.error("订单数据不完整");}}@RequestMapping(value = "/order/update")private CommonResult updateOrder(Order order) {if(orderService.updateById(order)){return CommonResult.success("修改订单成功",order);}else{return CommonResult.error("修改订单失败");}}@RequestMapping(value = "/order/delete")private CommonResult deleteOrder(Integer orderId) {if(orderService.deleteById(orderId)){return CommonResult.success("删除订单成功","订单id:"+orderId);}else{return CommonResult.error("删除订单失败");}}@RequestMapping(value = "/order/receipt")private CommonResult updateOrder(Integer orderId) {Order order = new Order();order.setOrderId(orderId);order.setOrderState("已收货");if(orderService.updateById(order)){return CommonResult.success("商品收货成功",order);}else{return CommonResult.error("商品收货失败");}}@RequestMapping(value = "/orderDetail/orderInfo")private 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);}if(resultList.size()!=0){return CommonResult.success("订单详情查询成功",resultList);}else{return CommonResult.error("订单详情查询失败");}}
}

用户授权等相关业务:

package com.qiu.controller;import com.qiu.entity.Role;
import com.qiu.service.RoleService;
//import com.qiu.util.general.CommonResult;
import com.qiu.util.general.CommonResult;
//import com.power.common.model.*;
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;/*** @description 用户授权等相关业务*/@RestController
@CrossOrigin
public class RoleController {final RoleService roleService;public RoleController(RoleService roleService) {this.roleService = roleService;}/*根据id查询用户*/@RequestMapping(value = "/role/findById")private CommonResult findById(Integer roleId) {Role role = roleService.selectById(roleId);if(role!=null){return CommonResult.success("查询成功",role);}else{return CommonResult.error("查询失败");}}/*根据角色名称查询角色*/@RequestMapping(value = "/role/findByKey")private CommonResult findByKey(String roleName) {Role role = roleService.selectByKey(roleName);if(role!=null){return  CommonResult.success("查询成功",role);}else{return CommonResult.error("查询失败");}}/*根据key查询用户*/@RequestMapping(value = "/role/existRoleName")private CommonResult existRoleName(Integer roleId,String roleName) {Boolean isExist = roleService.existsRoleName(roleId,roleName);if(isExist!=null){return  CommonResult.success("查询成功",isExist);}else{return CommonResult.error("查询失败");}}/*查询所有角色信息*/@RequestMapping(value = "/role/findAll")private CommonResult findAll() {List<Role> roles = roleService.selectAll();if(roles!=null){return CommonResult.success("查询成功",roles);}else{return CommonResult.error("查询失败");}}/*查询所有用户*/@RequestMapping(value = "/role/findAllUsable")private CommonResult findAllUsable() {List<Role> roles = roleService.selectAllUsable();if(roles!=null){return CommonResult.success("查询成功",roles);}else{return CommonResult.error("查询失败");}}@RequestMapping(value = "/role/count")private CommonResult findCount() {Integer count = roleService.selectCount();if(count!=null){return CommonResult.success("查询成功",count);}else{return CommonResult.error("查询失败");}}@RequestMapping(value = "/role/findIdByKey")private CommonResult findIdByKey(String key) {Integer id = roleService.selectIdByKey(key);if(id!=null){return CommonResult.success("查询成功","id: "+id);}else{return CommonResult.error("查询失败");}}@RequestMapping(value = "/role/add")private CommonResult add(Role role) {if(role!=null){if(roleService.insertData(role)){return CommonResult.success("添加成功",role);}else{return CommonResult.error("添加失败");}}return CommonResult.error("用户数据不存在");}@RequestMapping(value = "/role/update")private CommonResult update(Role role) {System.out.println(role);if(roleService.updateById(role)){return CommonResult.success("更新成功",role);}else{return CommonResult.error("更新失败");}}@RequestMapping(value = "/role/delete")private CommonResult delete(Integer roleId) {if(roleService.deleteById(roleId)){return CommonResult.success("删除成功",roleId);}else{return CommonResult.error("删除失败");}}
}

用户相关业务:

package com.qiu.controller;
import com.qiu.entity.User;
import com.qiu.entity.UserRole;
import com.qiu.entity.Vip;
import com.qiu.service.RoleService;
import com.qiu.service.UserRoleService;
import com.qiu.service.UserService;
import com.qiu.service.VipService;
import com.qiu.util.general.CommonResult;
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.*;/*** @description 用户相关业务*/@RestController
@CrossOrigin
public class UserController {final RoleService roleService;final UserService userService;final UserRoleService userRoleService;final VipService vipService;public UserController(UserService userService, RoleService roleService,VipService vipService, UserRoleService userRoleService) {this.userService = userService;this.roleService = roleService;this.userRoleService = userRoleService;this.vipService = vipService;}/*根据id查询用户*/@RequestMapping(value = "/user/findById")private CommonResult findById(Integer id) {User user = userService.selectById(id);if(user!=null){return CommonResult.success("查询成功",user);}else{return CommonResult.error("查询失败");}}/*根据帐号查询用户*/@RequestMapping(value = "/user/findByKey")private CommonResult findByKey(String key) {User user = userService.selectByKey(key);if(user!=null){return CommonResult.success("查询成功",user);}else{return CommonResult.error("查询失败");}}/*查询所有用户*/@RequestMapping(value = "/user/findAll")private CommonResult findAll() {List<User> users = userService.selectAll();if(users!=null){return CommonResult.success("查询成功",users);}else{return CommonResult.error("查询失败");}}/*判断某个用户是否还存在*/@RequestMapping(value = "/user/existKey")private CommonResult existKey(String key) {Boolean isExist = userService.existsWithPrimaryKey(key);if(isExist!=null){return CommonResult.success("查询成功",isExist);}else{return CommonResult.error("查询失败");}}/*查询用户状态*/@RequestMapping(value = "/user/userState")private CommonResult userState(String accountNumber) {Boolean state = userService.selectUserState(accountNumber);if(state!=null){return CommonResult.success("查询成功",state);}else{return CommonResult.error("查询失败");}}/*查询用户记录的总条数*/@RequestMapping(value = "/user/count")private CommonResult findCount() {Integer count = userService.selectCount();if(count!=null){if(count!=0){return CommonResult.success("查询成功",count);}else{return CommonResult.error("查询失败");}}else{return CommonResult.error("查询失败");}}//通过用户帐号去查询用户的id@RequestMapping(value = "/user/findIdByKey")private CommonResult findIdByKey(String key) {Integer id = userService.selectIdByKey(key);if(id!=null){if(id!=0){return CommonResult.success("查询成功","id: "+id);}else{return CommonResult.error("未查询到");}}else{return CommonResult.error("查询失败");}}//删除用户@RequestMapping(value = "/user/delete")private CommonResult delete(Integer userId) {if(userService.deleteById(userId)){return CommonResult.success("删除成功",userId);}else{return CommonResult.error("删除失败");}}@RequestMapping(value = "/user/author")private CommonResult author(Integer userId,@RequestParam List<Integer> roleId) {System.out.println(userId);System.out.println(roleId);if(userId!=null && roleId!=null && roleId.size()!=0){if(userRoleService.deleteById(userId)){UserRole userRole = new UserRole();userRole.setUserId(userId);for (Integer id : roleId) {userRole.setRoleId(id);userRoleService.insertData(userRole);}}return CommonResult.success("授权成功");}else{return CommonResult.error("角色授权数据不完整!");}}/*查询所有VIP用户*/@RequestMapping(value = "/vip/findAllVip")private CommonResult findAllVip() {List<Vip> vips = vipService.selectAll();if(vips!=null){return CommonResult.success("查询成功",vips);}else{return CommonResult.error("查询失败");}}/*查询VIP用户信息根据id*/@RequestMapping(value = "/vip/findVipById")private CommonResult findVipById(Integer vipId) {Vip vip = vipService.selectById(vipId);if(vip!=null){return CommonResult.success("查询成功",vip);}else{return CommonResult.error("查询失败");}}/*查询VIP用户信息根据id*/@RequestMapping(value = "/vip/findVipByKey")private CommonResult findVipByKey(String accountNumber) {Vip vip = vipService.selectByKey(accountNumber);if(vip!=null){return CommonResult.success("查询成功",vip);}else{return CommonResult.error("查询失败");}}/*判断用户信息是否存在*/@RequestMapping(value = "/vip/existsVip")private CommonResult existsVip(String accountNumber) {Boolean isExist = vipService.existsVip(accountNumber);if(isExist!=null){return CommonResult.success("查询成功",isExist);}else{return CommonResult.error("查询失败");}}//创建vip信息@RequestMapping(value = "/vip/addVip")private 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信息插入成功",vip);}else{return CommonResult.error("vip信息插入失败");}}//更新vip信息@RequestMapping(value = "/vip/updateVip")private CommonResult updateVip(Vip vip) {if(vipService.updateById(vip)){return CommonResult.success("vip信息更新成功",vip);}else{return CommonResult.error("vip信息更新失败");}}//删除vip信息@RequestMapping(value = "/vip/deleteVip")private CommonResult deleteVip(Integer vipId) {if(vipService.deleteById(vipId)){return CommonResult.success("删除成功",vipId);}else{return CommonResult.error("删除失败");}}
}

源码获取:博客首页 "资源" 里下载!

Java项目:在线商城系统(前后端分离+java+vue+Springboot+ssm+mysql+maven+redis)相关推荐

  1. Java项目:仿小米商城系统(前后端分离+java+vue+Springboot+ssm+mysql+maven+redis)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 本系统功能包括: 基于vue + Springboot前后端分离项目精简版仿小米商城 系统,注册登录,首页展示,商品展示,商品 ...

  2. Java项目:网上电商项目(前后端分离+java+vue+Springboot+ssm+mysql+maven+redis)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 本系统功能包括: 一款基于Springboot+Vue的电商项目,前后端分离项目,前台后台都有,前台商品展示购买,购物车分类, ...

  3. Java项目:员工管理系统(前后端分离+java+vue+Springboot+ssm+mysql+maven+redis)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 本系统功能包括:分为前端翻后端部分,包括用户,区分晋通用户以及誉里员用户,包括首页展示,部门管理,人事管理,员工管理三个模块等 ...

  4. Java项目:朴素风个人博客系统(前后端分离+java+vue+Springboot+ssm+mysql+maven+redis)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 本系统功能包括: 基于vue + Springboo痼J后端分离项目个人博客系统,注册 登录,首页展示,喜爰图书展示,后台图书 ...

  5. Java项目:个人博客系统(前后端分离+java+vue+Springboot+ssm+mysql+maven+redis)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 本系统功能包括:文章展示.热门文章.文章分类.标签云用户登录评论.匿名评论用户留言.匿名留言评论管理.文章发布.文章管理文章数 ...

  6. Java项目:在线小说阅读系统(前后端分离+java+vue+Springboot+ssm+mysql+maven+redis)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 本系统功能包括: 普通用户端登录注册,小说的分类,日榜,月榜,年榜, 小说的阅读,分章节,小说的评论,收藏,推荐等等,以 及后 ...

  7. Java项目:进销存管理系统(前后端分离+java+vue+Springboot+ssm+mysql+maven+redis)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 本系统功能包括: 库存管理,入库管理,出库管理,往来管理,基础资料, 系统管理,消息中心,系统监控等等. 二.项目运行 环境配 ...

  8. Java项目:精美网上音乐平台(前后端分离+java+vue+Springboot+ssm+mysql+maven+redis)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 本系统功能包括: 音乐播放 用户登录注册 用户信息编辑.头像修改 歌曲.歌单搜索 歌单打分 歌单.歌曲评论 歌单列表.歌手列表 ...

  9. Java项目:成绩管理系统(前后端分离+java+vue+Springboot+ssm+mysql+maven+redis)

    源码获取:博客首页 "资源" 里下载! 一.项目简述 本系统功能包括: 超豪华成绩管理系统,学生,教师,管理员三类用户集 成,课程表管理,成绩查询,成绩详情数据统计,课程录 入,用 ...

最新文章

  1. FastAPI 之自动化测试数据库接口
  2. nyoj 791 Color the fence(贪心)
  3. 普通话/汉语发音口型大全
  4. metasploit使用篇(windows)
  5. 数据分析在企业中的应用
  6. 下载devc++和codeblocks记录
  7. web 3d 资源库大全
  8. Chrome开发者工具对于异常请求不显示Response内容
  9. windows命令行包管理工具 -Scoop
  10. 亲测好用的万能工具箱:Parallels Toolbox for mac中文版
  11. 离线维基百科全书阅读器(wikireader)
  12. DICOM影像中的窗宽窗位
  13. 技嘉b365m小雕驱动工具_【黑苹果】技嘉B365M小雕+i5 9400F+RX590EFI分享
  14. latex 公式换行_如何在微信公众号中!编辑出漂亮的数学公式?
  15. JSP中用List list = new ArrayList();报错, List cannot be resolved to a type
  16. spring用注解无法灵活注入带参构造函数解决办法
  17. 【逆向工程】C/C++的反汇编表示详解(1)函数调用,栈平衡,变量与参数的内存布局
  18. Java入门概念回炉重造
  19. echarts tree默认展开_Echarts树形图展开和收缩
  20. 【pandas问题】UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xca in position 0: invalid continuati

热门文章

  1. Revit结构2021专业人士的选择:从入门到专业
  2. Linux从程序到进程
  3. 设计模式 之美 -- 工厂方法模式
  4. C++多线程:异步操作std::async和std::promise
  5. ceph osd混合部署和普通部署
  6. linux 系统崩溃完全没有操作空间的系统修复
  7. 树状数组的理解(前缀和 and 差分)
  8. 数据结构|-常见数据结构整理
  9. Study on Android【三】--Intent消息传递
  10. JavaScript 中的有限状态机